Let $k$ be a field (not necessarily algebraically closed). We call $k$-variety a scheme of finite type over $\mathrm{Spec}\left(k\right)$. Let $X$ be a geometrically reduced $k$-variety and $Y$ a $k$-variety.
The rest of the problem statement is as follows: Let $f,g:X\rightarrow Y$ two $k$-morphisms. We suppose that the set-wise applications $X\left(\bar{k}\right)\rightarrow Y\left(\bar{k}\right)$ induced by $f$ and $g$ coincide. We wish to show that $f=g$.
Question: How can it be shown that we can suppose $X$ and $Y$ to be affine?