Showing that there exists an automorphism of a cyclic group mapping a generator to another. I’m currently going through Lang’s Algebra, I’ve only recently started it, and I’m trying to do every proof left as an exercise. One such question is the following:

Let $G$ be a cyclic group, and let $a,b$ be two generators. Then there exists an automorphism of $G$ mapping $a$ onto $b$. Conversely, any automorphism of $G$ maps $a$ on some generator of $G$.

I think I was able to prove the second part of the statement (see below), but I am struggling with the first part.
For the second part, assume $f$ is an automorphism of a cyclic group $G$ with generator $a$, then there is a unique $x\in G$ such that $f(x)=a$. Since $G=\langle a\rangle$, we have for all $y\in G, y=f(x)^k=f(x^k)$. Since $f$ is an automorphism it has an inverse, then $\forall y\in G, \; f^{-1}(y)=x^k$ but $f^{-1}$ is an automorphism as well so $f^{-1}(y)=g\in G$, so $\forall g\in G, g=x^k$ with $f(x)=a$ hence $x$ is a generator. Hopefully that’s correct…?
Now for the first part of the statement, any endomorphism of a cyclic group $G$ such that $f(a)=b$ (where $a,b$ are generators of $G$) is surjective since $f(a^n)=f(a)^n=b^n$. But I’m not sure how to show that it can also be injective. I feel there’s something simple I’m missing here. Any help is appreciated.
 A: We use the result that the homomorphic image of a cyclic group is cyclic to prove part 2.
For part 1, we are supposed to prove the existence of an automorphism on the group $G$ mapping any two given generators of $G$, $a$ and $b$.
We will first prove that if a group homomorphism mapping the generator $a$
to another generator $b$ exists, it has to be bijective. If $\varphi\,:G\rightarrow G$ is a homomorphism (or an endomorphism, if you are specific about terminology) such that $\varphi(a)=b$ then $\varphi(a^n)=\varphi(a)^n=b^n$, and it follows that $\varphi$ is surjective. Moreover, if $a^k$ is in the kernel of $\varphi$, then $e=b^k=\varphi(a)^k=\varphi(a^k)$, so that the order of $b$ divides $k$. Finally, since the order of $a$ equals the order of $b$, by virtue of both of them being generators of $G$, it follows that $\varphi$ is injective, since $|a|=|\varphi(a)|$. Thus, $\varphi$ is an automorphism on $G$.
We now show the existence of the automorphism mapping the generator $a$
to another generator $b$ by explicit construction. If $x$ is a generator of $G$, then any element in the group is of the form $nx$ for some positive integer $n$. In particular, since $a$ is a generator, the other generator $b$ in question, also being a member of the group, is of the form $ma$ for some positive integer $m$. The mapping $x\mapsto mx\,\forall\,x\,\in\,G$ is the required homomorphism.
