I'm trying to prove the following:
Let $X,Y$ affine varieties (both irreducible) and a morphism $f:X\to Y$. The pullback $f^*:A(Y)\to A(X)$ is surjective $\Leftrightarrow$ $f$ is injective and $f(X)\subset Y$ is closed.
[correction: as shown in @MooS's answer, the statement above is false]
I was able to prove $(\Rightarrow)$ by observing that $A(\overline{f(X)})\simeq A(Y)/\ker(f^*)\simeq \text{im}(f^*)=A(X)$, so that $f$ gives an isomorphism between $X$ and $\overline{f(X)}$, so it must be injective and $f(X)=\overline{f(X)}$.
Now I'm having trouble proving $(\Leftarrow)$. If $f$ is injective and $f(X)=Y$ is closed, $f:X\to f(X)$ is a bijective morphism between affine varieties. It seems to me (I might be wrong) that in order to prove $f^*$ is surjective I should prove $f$ is an isorphism, but I can't see how to do that.
Is there a better way?
$f:\mathbb A^1 \to V(x^3-y^2), t \mapsto (t^2,t^3)$ is bijective, in particular it is injective with closed image, but $f^*: \mathbb C[x,y] \to \mathbb C[t], x \mapsto t^2, y \mapsto t^3$ is not surjective, since the image is $\mathbb C[t^2,t^2] \subsetneq \mathbb C[t]$.