If $G/Z(G)$ is cyclic, then $G$ is abelian

Continuing my work through Dummit & Foote’s “Abstract Algebra”, 3.1.36 asks the following (which is exactly the same as exercise 5 in this related MSE answer):

Prove that if $G/Z(G)$ is cyclic, then $G$ is abelian. [If $G/Z(G)$ is cyclic with generator $xZ(G)$, show that every element of $G$ can be written in the form $x^az$ for some $a \in \mathbb{Z}$ and some element $z \in Z(G)$]

The hint is actually the hardest part for me, as the quotient groups are somewhat abstract. But once I have the hint, I can write:

$g, h \in G$ implies that $g = x^{a_1}z_1$ and $h = x^{a_2}z_2$, so
\begin{align*}gh &= (x^{a_1}z_1)(x^{a_2}z_2)\\\
&= x^{a_1}x^{a_2}z_1z_2\\\
& = x^{a_1 + a_2}z_2z_1\\\
&= \ldots = (x^{a_2}z_2)(x^{a_1}z_1) = hg.
\end{align*}
Therefore, $G$ is abelian.
1) Is this right so far?
2) How can I prove the “hint”?

We have that $G/Z(G)$ is cyclic, and so there is an element $x\in G$ such that $G/Z(G)=\langle xZ(G)\rangle$, where $xZ(G)$ is the coset with representative $x$. Now let $g\in G$. We know that $gZ(G)=(xZ(G))^m$ for some $m$, and by definition $(xZ(G))^m=x^mZ(G)$. Now, in general, if $H\leq G$, we have by definition too that $aH=bH$ if and only if $b^{-1}a\in H$. In our case, we have that $gZ(G)=x^mZ(G)$, and this happens if and only if $(x^m)^{-1}g\in Z(G)$. There then exists a $z\in Z(G)$ such that $(x^{m})^{-1}g=z$, and so $g=x^mz$. The hint is then proved, and the rest is identical to the work you did.