Suppose $a_1, \dots, a_n$ generate an abelian group $A$, and for any abelian group $B$, and any $b_1, \dots, b_n \in B$ we can find a homomorphism $\varphi: A \to B$ given by $\varphi(a_i) = b_i ~ \forall i$. Prove that $A$ is a free abelian group with basis $(a_1, \dots, a_n)$.
My idea: take $B$ to be the free abelian group of rank $n$, and we pick our $b_1, \dots, b_n$ to be a basis for $B$. Then we have a homomorphism that takes each generator of $A$ to a generator of $B$. Moreover, the order of each $b_i$ has to divide the order of the $a_i$, but the $b_i$ have infinite order and thus the $a_i$ have to as well. So we have an epimorphism of $A$ onto $B$. So $A/Ker(\varphi) \cong B$.
This is where I get stuck. I'm not sure how to show that the kernel is trivial. Any help will be appreciated.
Suppose $a \in \ker \varphi$. Write $a = \sum_1^n k_i a_i$ where $k_i \in \mathbb{Z}$.
Then $\sum_1^n k_i b_i =\varphi(a) =0$, so since the $b_i$ form a basis, it follows that all $k_i=0$.
Thus $a = \sum_1^n k_ia_i = \sum 0a_i = 0$.
Thus $\ker \varphi$ is trivial.
(A better proof would be to use Derek Holt's comment.)