Assume $f \in \mathbb{C}[x,y]$ a polynomial such that the affine algebraic curve $X=V(f)$ has no singular points. Then there is a natural structure of non-compact Riemann surface on $X$, which can be made into compact Riemann surface by adding several (finitely many) points.
Question:
Is this compactification the same thing as taking projective closure of the curve $X$? If so, how does one generally define the holomorphic maps in the neighborhoods of the "points at infinity"?
Up until now I have thought so. However, I came across the following example (I will further assume that the projective closure is indeed the compactification):
Consider a polynomial
$$f(x,y)=x^ 2-g(y), $$
where $g(y)$ is a complex polynomial of an even degree $k, \; k>2$ and, for simplicity's sake, leading coefficient $1$. Assume further that $g$ has $k$ distinct roots. Say I want to compute the genus of the compactification of $V(f)$.
Then the projective closure of $V(f)$ is $V_{proj}(f^{*}),$ where
$$f^{*}(x,y,z)=x^2z^{k-2}-y^k-(\text{other monomials of }g\text{ multiplied by some nonzero power of }z)$$
Now I want to compute the points at infinity, this leads to the equation $y^k=0,$ hence $y=0$ and thus, there is only one such point: $(1:0:0)$.
However, consider the holomorphic map $\pi: V_{proj}(f^*) \rightarrow \mathbb{S}$ defined by $\pi(x:y:1)=y, \pi(1:0:0)=\infty$. Then it is easy to compute that the degree of $\pi$ is $2$ and that $b(\pi)=k+1$ (where $b(\pi):= \sum_{P \in V_{proj}(f^*)}(e_P-1)$ and $e_P$ denotes the ramification index at the point $P$). So by Riemann-Hurwitz formula I get
$$g(V_{proj}(f^*))=1+(g(\mathbb{S})-1)\deg \pi +\frac{1}{2}b(\pi)=\frac{k+1}{2}-1,$$
which is not an integer. (Note that if tha considered curve had two points at infinity, the number $b(\pi)$ would be even and everything would work fine).
So additional question is:
If the compactification can really be obtained via the projective closure, where is the mistake in the previous example?
Thanks in advance for any help.