Suppose M is a module over integral domain R. If M is generated by k elements, then $rank(M) \leq k$ (Confirm my proof ?) I am self studying algebra and am wondering if the following proof works.
By rank we mean the supremum of cardinalities of linearly independent sets. Now this is equivalent to the supremum of cardinalities of maximal linearly independent set which is equal to the cardinality of any maximal independent set as any two maximal independent sets have the same cardinality.
Here is my argument:
I said let $B=\{a_1,...a_n\}$ be a maximal linearly independent subset of M of cardinality rank(M). (We can always choose such a B whose cardinality is the rank of M).
Then consider passing to the field of fractions F. B is easily seen to be a linearly independent set over F by clearing denominators as R is an integral domain: Namely if $(c_1/d_1)a_1 + ... (c_n/d_n) a_n=0$ we have by multiplying through by $d_1 d_2... d_n$   that $(c_1 d_2... d_n) a_1 + ... + (c_n d_1...d_{n-1}) a_n =0$ but now these coefficients are in R and hence they must all equal $0$ by linear independece over R. But R is integral domain and the $d_i$ are non zero being denominators, so each $c_i=0$ and hence we see that B is an independent subset over F as well. Now M is finitely generated over R, so by embedding M in its quotient field, M is also finitely generated over F obviously. Now if this finite set that generates M has cardinality k, then the basis of M as a vector space over F has cardinality less or equal to k being a minimal spanning set. Finally B being a independent subset of a vector space M has cardinality less than the cardinality of the basis which has cardinality less than k. Hence B has cardinality less than k. But B is a maximal linearly independent set, hence $rank(M)\leq k$.
Is my proof correct? I realise I have assumed that the rank is finite, but assuming it is finite, is it a correct proof? Thanks in advance.
Edit: Oh wait, I guess I can't really do this as M is not free.. I was thinking M is isomorphic to R^d for some d hence pass to F^d but M is not necessarily free. 
 A: As you have mentioned, this proof seems to assume $M$ is free in order to "pass to the field of fractions".  However, there actually is a way to "pass to the field of fractions" and make the proof work for arbitrary modules.  Namely, you can take the tensor product $F\otimes_R M$.
If you're unfamiliar with tensor products, here's a concrete description of how this works in this particular case.  Roughly, we apply the "field of fractions" construction to $M$.  More precisely, an element of $F\otimes_R M$ is an equivalence class of fractions $\frac{m}{r}$ for $m\in M$ and $r\in R\setminus\{0\}$, where we consider two fractions $\frac{m}{r}$ and $\frac{n}{s}$ to be equivalent if there exists $t\in R\setminus\{0\}$ such that $t(sm-rn)=0$.  You can then verify that the usual rules of addition and multiplication of fractions makes this an $F$-module.  (Note that if $M$ is torsion-free, you can leave out $t$ in the equivalence relation, since $t(sm-rn)=0$ implies $sm-rn$ in that case.  If $M$ has torsion, though, you need to allow such a $t$, and doing so causes all torsion elements of $M$ to become $0$ in $F\otimes_R M$.)
To apply your argument, then, you need to know two facts about $F\otimes_R M$.  First, you need to know that a linearly independent subset of $R$ gives a linearly independent subset of $F\otimes_R M$ (replacing your linearly independent elements $a_i$ with the fractions $\frac{a_i}{1}$).  This works almost just like how you said by clearing denominators: if $$\frac{c_1}{d_1}\frac{a_1}{1} + \dots+ \frac{c_n}{d_n} \frac{a_n}{1}=0$$ then by our equivalence relation on fractions that means $$t((c_1 d_2\dots d_n) a_1 + \dots + (c_n d_1\dots d_{n-1}) a_n) =0$$ for some $t\in R\setminus\{0\}$.  The only difference between this and what you said is the additional factor of $t$.  However, we can just absorb $t$ into the coefficients of the $a_i$ to again conclude that the $c_i$ are $0$, just as you did.
Second, you need to know that if $M$ is generated by $k$ elements as an $R$-module, then $F\otimes_R M$ is generated by $k$ elements as an $F$-module.  The proof is again simple: if $b_1,\dots,b_k$ generate $M$, then the fractions $\frac{b_1}{1},\dots,\frac{b_k}{1}$ generate $F\otimes_R M$ (they clearly generate all fractions of the form $\frac{m}{1}$ just using scalars from $R$, and then you can get $\frac{m}{r}$ by multiplying by the scalar $\frac{1}{r}\in F$).
Finally, let me note that your proof does not actually require anything to be finite.  It works just as well if $B$ is an infinite set (though the linear combinations of elements of $B$ you consider will of course involve only finitely many elements of $B$ at a time).
