Why the number of points where $f$ ramifies is finite?

I know roughly that there is a theorem in complex analysis saying that if $f$ has degree $e_x>1$ at point $x$, which is $f(z)=(x-z)^{e_x}g(z)$, then $f^{-1}(y)$ has $e_x$ different preimages in a neighborhood of $y$.

In a complex Riemann surface, we have the same result considering $f$ in the local coordinates.

We call that $f$ ramifies at point $x$ if $e_x>1$.

I was told that the number of points where $e_x>1$ is finite.

Can anyone tell me why? Is this result valid only in compact Riemann surface or generally?

update:

I realized that $f$ has digree $e_x$ at $x$ sould be $f(z)-f(x)=(z-x)^{e_x}g(z)$ rather than what I originally posted.

Sorry for trouble..

-
Doesn't $\sin^2 z$ have an infinite number of points $x$ where $e_x > 1$? – Antonio Vargas Jan 9 '13 at 2:09
@AntonioVargas, so the result may be valid only on compact set? – hxhxhx88 Jan 9 '13 at 2:19
What is $k$?${}$ – Antonio Vargas Jan 9 '13 at 2:22
@AntonioVargas, it is a typo, it should be $e_x$ – hxhxhx88 Jan 9 '13 at 2:48
Ah, ok. Also, are you assuming that $f$ is holomorphic? – Antonio Vargas Jan 9 '13 at 2:49

Suppose there are infinitely many $x$ for which $e_x>1$. Any infinite subset of a compact set has an accumulation point in the set, so $f(z) = 0$ on a sequence which converges in your domain and must be zero by the identity theorem.

If $f$ is nonzero, it must have only finitely-many such zeros.

Now, if the domain isn't compact, then $f$ may indeed have infinitely many such $x$, for example if $f(z)=\sin^2 z$.

-
I'm sorry I think I mistook the meaning of degree in my post, it should be $f(z)-f(x)=(z-x)^{e_k}g(z)$. But your argument is quite fine because if $e_x>1$ for infinitely number of $x$, we can consider $f'(z)$ to say it must be $0$, then $f$ must be constant. anyway, thank you! – hxhxhx88 Jan 9 '13 at 3:38

If $f:X \to Y$, a non-constant holomorphic map of Riemann surfaces, has ramification degree $e$ in a n.h. of a point $x$, then we may choose local coords. in the source and target so that $x$ and $f(x)$ both lie at the origin, and $f$ is given by $z \mapsto z^e$. Note that every point other than zero in this n.h. of $x$ is not a ram. point. So every point $x$, whether or not it is a ramification point (i.e. whether or not $e > 1$) has a n.h. $U$ so that $U\setminus \{x\}$ contains no ramification points.

Conclusion: the set of ramification points is closed and discrete.

In particular, if $X$ is compact, then the set of ramification points is compact and discrete, thus finite. If $X$ is not compact, then the set of ramification points need not be finite (as the examples already given in the comments show).

-
Your answer is quite beautiful, thanks! – hxhxhx88 Jan 9 '13 at 5:13