Let $F$ be a free $R$-module, where $R$ is a PID, and $U \subseteq F$ be a submodule. Then $U$ is also free with $\mathrm{rank}(U) \leq \mathrm{rank}(F)$.
Proof. Let $(e_i)_{i \in I}$ be a basis of $F$. Choose a well-ordering $\leq$ on $I$ (this requires the Axiom of choice). Let $p_i : F \to R$ be the projection on the $i$th coordinate, i.e. $p_j(e_i) = \delta_{ij}$. Let $F_i$ be the submodule of $F$ generated by the $e_j$ with $j \leq i$. Let $U_i = U \cap F_i$. Then $p_i(U_i)$ is a submodule of $R$, that is an ideal, i.e. has the form $R a_i$ for some $a_i \in R$. Choose some $u_i \in U_i$ with $p_i(u_i)=a_i$. If $a_i=0$, we may, and will, choose $u_i=0$.
We claim that the $u_i \neq 0$ constitute a basis of $U$.
We first show that $\langle u_i : i \in I \rangle = U$. Let $u \in U$, so $u \in F$ and we can write $u = r_{i_1} e_{i_1} + \cdots + r_{i_n} e_{i_n}$ with $i_1 < \cdots < i_n$. For $n=0$ there is nothing to do, so let $n \geq 1$. We make an induction on the largest index $j := i_n$. We have $u \in U_j$ and $r_j = p_j(u) \in p_j(U_j) = R a_j$, say $r_j = s a_j = s p_j(u_j)$ for some $s \in R$. Then $p_j(u - s u_j) = 0$, i.e. the $e_j$-coefficient in $u - s u_j$ vanishes. By induction hypothesis, we know $u - s u_j \in \langle u_i : i \in I \rangle$, hence also $u \in \langle u_i : i \in I \rangle$.
To show linear independence, we assume that $0 = r_{i_1} u_{i_1} + \cdots + r_{i_n} u_{i_n} = 0 ~ (\star)$ with $i_1 < \cdots < i_n$. Again consider the largest index $j := i_n$. It suffices to prove $r_j=0$, because then we are done by induction on $n$. Applying $p_j$ to $(\star)$ yields $0 = r_{i_1} 0 + \cdots + r_{i_{n-1}} 0 + r_{j} a_j = r_j a_j$. Since $a_j \neq 0$ (otherwise, we would have $u_j = 0$), we conclude $r_j = 0$. $\checkmark$
--
PS: The same proof shows the more general result: If $R$ is a hereditary ring (every ideal of $R$ is projective over $R$), then any submodule of a free $R$-module is a direct sum of ideals of $R$.