# Meromorphic functions on $X(1)$ are rational functions of $j$

I'm reading the proof given by Diamond and Shurman that the field of meromorphic functions on $X(1)$ is the set of rational functions of $j$ and it seems I'm missing something.

Starting with $f$ meromorphic and nonconstant on $X(1)$, they construct a function $g$ that is a rational function of $j$ having the same poles and zeros as $f$ on the upper half-plane. They then say that this implies that both functions vanish to the same order at infinity because "for both functions, the total number of zeros minus poles is 0". Why is that last part true?

• For a compact Riemann Surface a meromorphic function has the same number of zeros as poles. Basically this follows from the Residue Theorem for Riemann Surfaces which says that the sum of the residues of a differential form equals zero. – sharding4 May 27 '18 at 0:47