Problem
Let $f:\Bbb{R}\times[0,1]\rightarrow\Bbb{R}$ be a continuous function and $\{x_n\}$ a sequence of reals converging to $x$. Define
$g_n(y)=f(x_n,y),\hspace{0.5cm}0\le y\le1$
$g(y)=f(x,y),\hspace{0.9cm}0\le y\le1$.
Show that $g_n$ converges to $g$ uniformly on $[0,1]$.
My attempt
From continuity of $f$, $g_n$ pointwise converges to $g$ on $[0,1]$.
Now for given $\epsilon>0$ and $0\le y\le1$, there exists positive integer $n_y$ such that
$|g_n(y)-g(y)|<\epsilon$, for all $n\ge n_y$.
Hence we obtain $\{(g_{n_y}(y)-\epsilon,g_{n_y}(y)+\epsilon)\}_{0\le y\le1}$ is an open convering of image of $g$. Now from continuity of $f$, $g$ is continuous. So $\{g(y):0\le y\le1\}$ is compact.
Hence there are $y_1,y_2,\dots,y_k\in[0,1]$ such that $\{(g_{n_{y_i}}(y_i)-\epsilon,g_{n_{y_i}}(y_i)+\epsilon)\}_{1\le i\le k}$ covers the image of $g$. If we put, $N=\operatorname{max}\{n_{y_i}:i=1,2,\dots,k\}$ then for all $y\in[0,1]$,
$|g_n(y)-g(y)|<\epsilon$, for all $n\ge N$.
Thus $g_n$ converges uniformly to $g$ on $[0,1]$.
Is the proof correct? If not then please pinpoint or improve. Thank you.
Another approach: Note the set $\{x_1,x_2,\dots\}\cup \{x\}$ is bounded, hence is contained in $[-M,M]$ for some positive $M.$ Since $[-M,M]\times [0,1]$ is compact, $f$ is uniformly continuous there.
Let $\epsilon >0.$ Then there exists $\delta>0$ such that $z,w\in[-M,M]\times [0,1],$ $ |z-w|< \delta,$ implies $|f(z)-f(w)|<\epsilon.$
Since $x_n\to x,$ we can choose $N$ such that $|x_n-x|<\delta$ for $n>N.$ For such $n,$ $|(x_n,y)-(x,y)| = |x_n-x|<\delta$ for all $y\in [0,1].$ Hence for $n>N,$ $|g(x_n,y)-g(x,y)|<\epsilon$ for all $y\in [0,1]$ as desired.