Now, define the function $g:X\to S$ ($S$ being a proper subset of $X$) as follows:
$$g(x):=\begin{cases}x&\text{if }x\in X\setminus \{x_i\mid i\in\mathbb N\}\\x_{i+1}&\text{if }x=x_i\end{cases}$$
By construction, the function $g$ is injective as well.
Infinite case $”\Leftarrow”$
By contraposition to finite case $”\Rightarrow”,$ if there is an injective function $f:X\to S,$ then $X$ is not finite, therefore $X$ is infinite.
Finite case $”\Leftarrow”$
By contraposition to the infinite case $”\Rightarrow”,$ if there is no injective function $g:X\to S,$ then $X$ is not infinite, therefore $X$ is finite.