Suppose I have a function $f$ of which we know that it is analytic in the set $\mathbb{C}\setminus S$, where $$S := \bigcup_{n=-\infty}^\infty S_n := \bigcup_{n=-\infty}^\infty\{ z \in \mathbb{C} : Im(z) = (2n+1) \pi \}.$$ (The set $\mathbb{C}\setminus S$ is thus nearly all of the space $\mathbb{C}$ except countably many vertical lines.)
Suppose also that $f$ is bounded and continuous in the whole complex plane $\mathbb{C}$.
Question: From these assumptions, does it follow that $f$ is actually analytic in all of $\mathbb{C}$? Below is my attempt to prove that it does. Does my proof seem valid? Is there an essentially easier way of proving it?
My proof: I assume it does, and my attempt to prove it is the following: Fix $z \in S_n$ for a fixed $n$ and consider the disk $B(z,1)$ which intersects with exactly one $S_n$, so $B(z,1) = U_1 \cup (B(z,1) \cap S_n) \cup U_2$, where $U_1$ is an open set above $S_n$ and $U_2$ is an open set below $S_n$. Now take a closed, positively directed curve $\gamma \in B(z,1)$, and denote the area it surrounds by $A$. By Morera's theorem it's enough to prove that $\oint_\gamma f(z) dz = 0$.
If $\gamma$ doesn't intersect $S_n$ we are ready by Cauchy's integral theorem, so assume it does. Now let $T = S_n \cap A$, and split $\gamma$ into $\gamma = \gamma_1 \cup \gamma_2$, where $\gamma_1$ is in $A_1 \cup S_n$, and $\gamma_2$ is in $A_2 \cup S_n$, and $\gamma_i$ are positively directed closed curves. Now $$\oint_\gamma f(z) dz = \oint_{\gamma_1} f(z) dz + \oint_{\gamma_2} f(z) dz$$
For each of these integrals, we may slighly move $\gamma_i$ so that it doesn't intersect $S_n$ and so that the integral changes with less than a given $\varepsilon$. This is possible, since $f$ is uniformly continuous in the compact set $\overline{B(z,2)}$ and $\gamma_i$ has a finite length. By Cauchy's integral theorem, the new integrals with the moved curves is $0$. We get that $| \oint_\gamma f(z) dz | < 2 \varepsilon$ and so it is zero.
Thus $f$ is analytic in $B(z,1)$, and since $z$ was arbitrary, it's analytic everywhere.
Remark: from Liouville's theorem it now follows that $f$ is actually constant.
Thank you for your help! :)