Regarding doubt in proof that every modular function can be represented as rational function of J. I am self studying analytic number theory from Tom M. Apostol Modular Functions and Dirichlet Series in Number Theory and I am stuck on this theorem on page 40. 

Theorem 2.8. Every rational function of $J$ is a
  modular function. Conversely, every modular function
  can be expressed as a rational function of $J$.
PROOF. The first part is clear. To prove the second,
  suppose $f$ has zeros at $z_1,z_2,\dots,z_n$ and poles
  at $p_1,p_2,\dots,p_n$ with the usual conventions about
  multiplicities. Let $$g(\tau) = \prod_{k=1}^n  \frac{ J(\tau) - J( z_k) } { J(\tau) - J( p_k) }   $$ 
  where a factor $1$ is inserted whenever $ z_k $ or $ p_k $  is $ \infty $ . Then $g$ has the same zeros 
  and poles as $f$ in the closure of $R_\Gamma$, each
  with proper multiplicity. Therefore, $\,f/g\,$ has no
  zeros or poles and must be constant, so $\,f\,$ is a
  rational function.

I am not able to understand "where a factor $1$ is inserted whenever $ z_k $ or $ p_k $  is $ \infty $".
I am not able to understand what purpose introducing this factor solves. 
The proof continues but except the above line. I have no doubts in proof. 
Can someone please explain. I have thought a lot about it but I can't get it. 
Also, I have no help as I am self studying and the university in which I am studying doesn't have a number theorist. 
 A: Your specific question was

I am not able to understand what purpose introducing this factor solves.

The explanation goes back to the beginning of of Section $2.4$
on Modular Functions on page $34$ where he defines what it
means for a modular function to have a pole of order $\,m\,$ at $\,i\infty\,$ using the leading term in its Fourier expansion. 
By the way, the statement of Theorem $2.8$ should have $\,\infty\,$ replaced with $\,i\infty\,$ instead.
The key observation is that you have to distinguish between
an ordinary pole or zero and a pole or zero at $\,i\infty.\,$
A similar situation holds for rational functions defined on
the extended complex plane Riemann sphere.
Each ordinary zero or pole at $\,w\,$ is associated with factors of $\,F_w(z):=(z-w)\,$ raised to an integer power whose absolute value is the multiplicity of the zero or pole. But $\,F_\infty(z) = (z-\infty)\,$ is not a valid function.
However, all of these $\,F_w(z)\,$ factors have a
similar behavior as $\,z\to\infty,\,$ in that they are 
asymptotically equivalent.
Because of this behavior at $\,\infty,\,$ we can define the order of a zero or pole at $\,\infty\,$ so that each factor of
$\,(z-w)\,$ is regarded as a pole at $\,\infty\,$
and further define $\,F_\infty(z):=1.\,$ This is essentially the
projective viewpont. Using this convention, we can now state
that any non-constant rational function has a equal number of zeros and poles (up to multiplicity), but some of the zeros and poles may be at $\,\infty.\,$
For example, the rational function $\,F_w(z)\,$
is said to have a simple zero at $\,w\,$ and a simple pole
at $\,\infty.\,$ Thus, we can now write
 $\,z-w = F_w(z)/F_\infty(z).\,$ Any products and quotients
of such factors would have an equal number of $\,F\,$ factors
in the numerator and denominator. A similar situation arises
in the case of modular functions with the point $\,\infty\,$
replaced by $\,i\infty\,$ and $\,F_w(z)\,$ replaced with
$\,J(z)-J(w).\,$
A: Let $q_k$ be the poles of $f$ on the upper half-plane. Then $$g(t)=f(t) \prod_k (J(t)-J(q_k))$$ has no poles on the upper half-plane, it has a pole of order $n$ at $i\infty$ thus $g(t)-C_n J(t)^n$ has a pole of order $\le n-1$ at $i\infty$, repeat until $$h(t)=g(t)-\sum_{m=1}^n C_m J(t)^m$$ has no pole, since the modular curve is a compact Riemann surface, $|h(t)|$ attains its maximum at $a$, taking a chart $\phi(0)=a$ then $h \circ \phi$ is an analytic function attaining its maximum modulus which implies it is constant, by analytic continuation $h$ is constant and $$f(t) = \frac{h(a)+\sum_{m=1}^n C_mJ(t)^m}{\prod_k (J(t)-J(q_k))}$$
