Endomorphisms $\mathbb Z^n \to \mathbb Z^n$ and finiteness of the cokernel I’m trying to solve this problem:

given $F=\mathbb{Z}^n$ and $\phi\colon F \to F$, prove that $F/\operatorname{Im}\phi$ is finite if and only if $\det \phi \neq 0$.

So, my attempt:
$\det \phi \neq 0 \Rightarrow \operatorname{Ker} \phi \neq 0 \Rightarrow \dim(\operatorname{Im} \phi)<n$. And then I am stuck. Why $F/\operatorname{Im} \phi$ should be finite?
 A: There are perhaps simpler proofs; this one uses tensor products and the structure of finitely generated abelian groups.
Consider the exact sequence
$$\def\imphi{\operatorname{Im}\phi}
0\to\ker\phi\to\mathbb{Z}^n\xrightarrow{\phi}\mathbb{Z}^n\to\mathbb{Z}^n/\imphi\to0
$$
and tensor it with $\mathbb{Q}$; since $\mathbb{Q}$ is flat, tensoring preserves exactness. So we get the exact sequence
$$
0\to\ker\phi\otimes\mathbb{Q}\to\mathbb{Q}^n\xrightarrow{\hat\phi}\mathbb{Q}^n
\to(\mathbb{Z}^n/\imphi)\otimes\mathbb{Q}\to0
$$
where $\hat\phi$ is the endomorphisms obtained by identifying $\mathbb{Z}^n\otimes\mathbb{Q}$ with $\mathbb{Q}^n$.
We have $\det\hat\phi=\det\phi$ because the matrices of the endomorphisms are the same. Thus $\det\phi\ne0$ if and only if $(\mathbb{Z}^n/\imphi)\otimes\mathbb{Q}=0$, that is, if and only if $\mathbb{Z}^n/\imphi$ is torsion.
A finitely generated abelian group is torsion if and only if it is finite.
A: If $\det\phi=0$, then the $(\operatorname{Im}\phi)\otimes \Bbb R$ is a proper subspace, hence does not contain one of the standard base vectors, say $e_k\notin (\operatorname{Im}\phi)\otimes \Bbb R$. Then $me_k\notin (\operatorname{Im}\phi)\otimes \Bbb R$ for all $m\ne 0$ and hence $e_k$ generates a supbgroupg $\cong \Bbb Z$ in $\Bbb Z^n/\operatorname{Im}\phi$.
On the other hand, if $\det\phi\ne 0$, then the $\phi(e_i)$ are a basis of the vector space $\Bbb Q^n$. Hence for every $x\in \Bbb Z^n$ there are rationals $q_i$ such that $x=\sum q_i \phi(e_i)$. After multiplication with the common denominator, we see that an integer multiple of $x$ is in $\operatorname{Im}\phi$. Thus all elements of $\Bbb Z^n/\operatorname{Im}\phi$ have finite order. A n abelian group that is finitely generated by elements of finite order is finite.
A: Let $e_1, \dots, e_n$ be the canonical basis of $\mathbb Z^n$ and let $h_i=\phi(e_i)$.
Then $h_1, \dots, h_n$ generate $H$, the image of $\phi$. 
Moreover, $(h_1, \dots, h_n)= (e_1, \dots, e_n) A$ for some integer matrix $A$.
We have $\det (A) I= A \operatorname{adj} (A)$ and so
$$
(h_1, \dots, h_n)\operatorname{adj}(A)= (e_1, \dots, e_n) \det (A) I
$$
This implies that $(\det A)e_i \in H$, and so $H$ has finite index, at most $\det A$.
That's one direction.
