I want to prove the following theorem
If $f$ is continuous on $\mathbb{C}$ and analytic in $\{ z\mid \operatorname{Im}(z) \neq 0\}$, then $f$ is analytic in $\mathbb{C}$.
First I know from Morera's theorem, continuous function $f$ becomes analytic if $\int_\Gamma f(z)dz=0$ for any closed contour $\Gamma$ in the domain $D$.
Since $\operatorname{im}(z)=0$ implies $z \in \mathbb{R}$, I see $f$ is analytic in $\mathbb{C} \setminus \mathbb{R}$ but want to extend this to $\mathbb{C}$.
I saw A continuous function $f$ is analytic everywhere except along a simple closed contour $C$ in domain $D$, then $f$ is analytic everywhere in $D$. this post, but for me, it seems too complicated. I think there is a simple way to prove or show this theorem. Maybe my approach with using Morera's theorem is a bad starting point.