This follows from the following theorem, which is a common ingredient in the proof of the structure theorem for finitely generated abelian groups:
Theorem. Let $r\gt 0$ be a positive integer, and let $H$ be a subgroup of $\mathbb{Z}^r$. Then there exists a basis $a_1,\ldots,a_r$ of $\mathbb{Z}^r$, an integer $d$, $0\leq d\leq r$, and positive integers $m_1,\ldots,m_d$ such that $m_1|m_2$, $m_2|m_3,\ldots,m_{d-1}|m_d$ such that $m_1a_1,\ldots,m_da_d$ is a basis for $H$. In particular, $H$ is free and finitely generated.
You can see a proof of this in this previous answer.
To see how this proves the result, suppose that $G$ is abelian and finitely generated by $g_1,\ldots,g_r$. Let $H$ be a subgroup of $G$. There is a surjection $\mathbb{Z}^r\to G$ given by mapping the standard basis vector $\mathbf{e}_i$ to $g_i$; the subgroup $H$ corresponds to a subgroup $\mathcal{H}$ of $\mathbb{Z}^r$ by the isomorphism theorems. By the Theorem, $\mathcal{H}$ is finitely generated, and hence its image, $H$, is also finitely generated (generated by the images of the generators of $\mathcal{H}$).
In what you've done, you even may suppose $0\le e_i<n_i$.
The other way, observe that, if a group $G$ contains a non-torsion element $g$, the subgroup $\langle\,g\,\rangle$ is isomorphic to $\mathbf Z$, hence $G$ contains an infinite subgroup.
Best Answer
The theorem actually holds in a much larger setting: that of modules over Principal Ideal Domains. But I will restrict myself to the case of abelian groups.
Theorem Let $A$ be a free abelian group of finite rank $n$, and let $H$ be a subgroup of $A$. Then there exists a basis $a_1,\ldots a_n$ of $A$, and integer $d_1,\ldots,d_r$ with $0\leq r\leq n$, $1\leq d_1|d_2|\cdots|d_r$, such that $d_1a_1,\ldots,d_ra_r$ is a basis for $H$. In particular, $H$ is free of rank $r\leq n$.
Proof. If $H=\{0\}$, then we may take $r=0$, and $H$ is free of rank $0$. So we may assume that $H\neq\{0\}$.
We proceed by induction on $n$, the rank of $A$. If $n=1$, then $A$ is cyclic, and $H$ is a subgroup of a cyclic group. Therefore, $A=\langle a\rangle$, and $H=\langle da\rangle$ for some $d$, and we are done: $H$ is infinite cyclic, hence free of rank 1.
Assume now the result holds for free groups of rank less than $n$. Let $S$ be the set of all integers $d$ for which there exists a basis $b_1,\ldots,b_n$ of $A$ and integers $k_2,\ldots,k_n$ such that $db_1+k_2b_2+\cdots+k_nb_n\in H$. Since $0\in H$, $S$ is nonempty. Moreover, $S$ is closed under sums and inverses. That is, $S$ is a subgroup of $\mathbb{Z}$. Note also that, if $b_1,\ldots,b_n$ is a basis for $A$, and $k_1b_1+k_2b_2,\ldots,k_nb_n\in H$, then $k_i\in S$ for every $i$, $1\leq i\leq n$, since $b_i,b_1,\ldots,b_{i-1},b_{i+1},\ldots,b_n$ is also a basis for $A$.
Now, since $H\neq\{0\}$, $S$ contains some nonzero integer. Therefore, $S=\langle d_1\rangle$ for some positive integer $d_1$. Let $h_1\in H$, and $b_1,\ldots,b_n$ be a basis of $A$ such that $h_1 = d_1b_1+k_2b_2+\cdots k_nb_n$ is a witness to the fact that $d_1\in S$. Then since $k_i\in S$ for every $i$, it follows that $d_1|k_i$; thus, we may write $k_i = d_i\ell_i$ with $\ell_i\in\mathbb{Z}$. Let $a_1 = b_1 + \ell_1b_2+\cdots + \ell_n b_n$. Then $h_1=d_1a_1$.
Since $b_1,b_2,\ldots,b_n$ is a basis for $A$, the definition of $a_1$ guarantees that $a_1,b_2,\ldots,b_n$ is also a basis for $A$. If $h\in H$ is written as a linear combination of $a_1,b_2,\ldots,b_n$, then we will have $h=k_1a_1+k_2b_2+\cdots+k_nb_n$; since $d_1|k_1$, we can rewrite it as $h = mh_1 + k_2b_2+\cdots + k_nb_n$.
We define two subgroups of $H$: $$\begin{align*} H_0 &= \langle h_1\rangle\\ H_1 &= \{ h\in H\mid h\in\langle b_2,\ldots,b_n\rangle\}. \end{align*}$$ From the observation above we see that $H=H_0+H_1$. Moreover, $H_0\cap H_1=\{0\}$, since $a_1,b_2,\ldots,b_n$ are a basis. Thus, $H=H_0\oplus H_1$.
Let $A_1 = \langle b_2,\ldots,b_n\rangle$. Then $A_1$ is free or rank $n-1$, and $H_1$ is a subgroup of $A_1$; by the induction hypothesis, there exists a basis $a_2,\ldots,a_n$ of $A_1$, integers $d_2,\ldots,d_r$ with $1\leq d_2|d_3|\cdots|d_r$, such that $d_2a_2,\ldots,d_ra_r$ are a basis for $H_1$.
Since $H=H_0\oplus H_1$, it follows that $d_1a_1,d_2a_2,\ldots,d_ra_r$ are a basis for $H$; since $A=\langle a_1\rangle\oplus\langle A_1$, it also follows that $a_1,\ldots,a_n$ is a basis for $A$. The only thing that remains to be proven is that $d_1|d_2$.
But, indeed, $a_1,\ldots,a_n$ is a basis for $A$, and $d_2a_2\in H$; hence, by definition given before, we know that $d_2\in S=\langle d_1\rangle$, so $d_1|d_2$. This proves the theorem. $\Box$
The proof of the theorem tells you how to go about finding a basis.
In practice, given a set of generators of a subgroup $H$ of $\mathbb{Z}^n$, one uses the procedure from the Smith normal form to produce the basis guaranteed by the theorem, and to easily compute the index of $H$ in $\mathbb{Z}^n$.