Show that if we exchange elements in 2 different basis will still give us a basis. I came across a proof of the following theorem:

Let V be a free module over a division ring D. Suppose X and Y are two finite basis of V, then |X| = |Y|.

that uses the fact that if we exchange elements in 2 different basis, we will still get a basis. Say $X = \{x_1, x_2, ..., x_n\}$ and $Y = \{y_1, ..., y_k\}$, then $\{x_1, x_2, ..., x_{n-1}, y_k\}$ is still a basis. 

However, I am having trouble proving that, I can't show that if $0 = a_1 x_1 + ... a_n y_k$, then all the coefficients are 0. Can someone teach me how to solve this? Thanks
You have to be more precise.

First of all, it is convenient to assume that $k \le n$.

Then, $y_{k}$ will be a non-zero linear combination of the $x_{i}$. This means that when you write out $y_{k}$ as a linear combination of the $x_{i}$, at least one of the coefficients is non-zero. Permuting the $x_{i}$, one may assume that it is precisely the coefficient of $x_{n}$ that is non-zero.

Now you can proceed safely. That is, you have
$$
y_{k} = a_{1} x_{1} + \dots + a_{n} x_{n},
$$
with $a_{n} \ne 0$. So
$$
x_{n} = a_{n}^{-1} (y _{k} - a_{1} x_{1} - \dots - a_{n-1} x_{n-1}).
$$
This shows that $x_{1}, \dots, x_{n-1}, y_{k}$ is a system of generators, as
$$
\langle x_{1}, \dots, x_{n-1}, y_{k} \rangle \supseteq \langle x_{1}, \dots, x_{n-1}, x_{n} \rangle = V.
$$

If
$$
b_{1} x_{1} + \dots + b_{n-1} x_{n-1} + c y_{k} = 0,
$$
then
$$
(b_{1} + c a_{1}) x_{1} + \dots + (b_{n-1} + c a_{n-1}) x_{n-1} + c a_{n} x_{n} = 0.
$$
This implies $c = 0$, as $a_{n} \ne 0$, and thus all $b_{i}$ are zero. It follows that $x_{1}, \dots, x_{n-1}, y_{k}$ are also linearly independent.
Let $X=\{x_1, x_2\}$, $Y=\{y_1, y_2\}$ with $y_1=x_2$, $y_2=x_1$. Now $\{x_1, y_2\} = \{x_1\}$ is not a basis in general. Hence, your statement is wrong.