this was a true and false question which I mistakenly thought was false.
My reasoning was thus:
Let the function $f: \mathbb{R} \rightarrow \mathbb{Z}$ be injective. It follows that for every element $x \in \mathbb{R}$, there exists a unique $y \in \mathbb{Z}$ such that $f(x)=y$. But this would imply that $|\mathbb{R}| \leq |\mathbb{Z}|$, which is contradiction since $|\mathbb{R}|$ is uncountable and $|\mathbb{Z}|$. Therefore there is no function $f: \mathbb{R} \rightarrow \mathbb{Z}$ such that $f$ is injective.
Could someone tell me where I went wrong?
You have the sides wrong. Saying that $f\colon A\to B$ is a function means that there is a single $b\in B$ such that $(a,b)\in f$ (because $f$ is a subset of $A\times B$; such unique element is denoted by $f(a)$).
The function is injective if, for every $b\in B$ there exists at most one element $a\in A$ such that $f(a)=b$. (Note that is quite different from what you're saying.)
There are infinitely many functions $\mathbb{R}\to\mathbb{Z}$, but none of them is injective. Indeed, as you observe, this would imply that $|\mathbb{R}|\le|\mathbb{Z}|$, so $|\mathbb{R}|=|\mathbb{Z}|$, against the well known fact that $\mathbb{R}$ is not countable.