Uniform convergence on dense subset and continuity of the limit I got stuck in the proof of the following statement:

Let  $X$ be a topological space, let $D\subset X$ be dense in X, let $f_n:X\to \mathbb{C}$ be continuous on X for each $n\in \mathbb{N}$, where $\mathbb{C}$ is complex numbers. Let $f:X\to \mathbb{C}$. Suppose that $f_n\to f$ pointwise on $X$ and uniformly on $D$. Then $f$ is continuous on $X$.

My attempt is the following: Given $x$ and $\epsilon>0$,

*

*We can find  neighborhood $V_n$ of $x$ such that $t\in V_n$ implies that $\mid f_n(t)-f_n(x)\mid <\epsilon/4$.

*There exists $N$ that depends on $x$ such that $n\geqq N$ implies that $\mid f_n(x)-f(x)\mid<\epsilon/4$.

*Choosing $K$ so that $n\geqq K$ implies that $\mid f_n(t)-f(t)\mid<\epsilon/4$ for all $t\in D$.

Setting $M=\max\{N,K\}$, I tried to take $U=\cup_{n\geqq M} V_n$. Then $t\in U$ implies that
$$
\mid f(t)-f(x)\mid \leqq \mid f(t)-f_n(t)\mid+\mid f_n(t)-f_n(x)\mid+\mid f_n(x)-f(x)\mid
$$
Now the last two terms after the inequality are $<\epsilon/4$, however, I could not find a way to say a similar thing for the first one. Also, I did not use the fact that $D$ is dense. Any help is greatly appreciated!

Fix $x_0 \in X$. Since $f_n \to f$ uniformly on $D$, there exists some $N$ such that $\sup_{x \in D}|f_n - f_m| < \epsilon$ whenever $n,m \geq N$.
Now, by the continuity of $f_N$, choose a neighborhood $U_N$ of $x_0$, such that $|f_N(x)-f_N(y)| < \epsilon$ for all $y \in U_N$.
Pick $y_0 \in U_N$. Then, Since $f_n \to f$ pointwisely in $X$, there exists some large $n \geq N$ such that $|f_n(x_0)-f(x_0)| < \epsilon$ and $|f_n(y_0)-f(y_0)| < \epsilon$. Fix this $n$, and find neighborhood $U_n(x_0)$ of $x_0$, such that $|f_n(x_0) - f_n(y)| < \epsilon$ for all $y \in U_n(x_0)$. Similarly find such neighborhood $U_n(y_0)$ of $y_0$.
Next we utilize the density of $D$. Find some $x_D \in U_n(x_0) \cap U_N \cap D$, and similarly find $y_D \in U_n(y_0) \cap U_N \cap D$.
Finally,
$$
\begin{aligned}
|f(x_0)-f(y_0)| & \leq |f(x_0) - f_n(x_0)| + |f(y_0) - f_n(y_0)| + |f_n(x_0) - f_n(y_0)| \\
& < 2\epsilon + |f_n(x_0) - f_n(y_0)| \\
& < 2\epsilon + |f_n(x_0) - f_n(x_D)| + |f_n(x_D) - f_n(y_D)| + |f_n(y_n) - f_n(y_D)| \\
& < 4\epsilon + |f_n(x_D) - f_n(y_D)| \\
& < 4\epsilon + |f_n(x_D) - f_N(x_D)| + |f_N(x_D) - f_N(y_D)| + |f_N(y_D) - f_n(y_D)| \\
& < 6 \epsilon + |f_N(x_D) - f_N(y_D)| \\
& < 6 \epsilon + |f_N(x_D) - f_N(x)| + |f_N(y_D) - f_N(x)| \\
& < 8 \epsilon.
\end{aligned}  
$$
Sorry about the lengthy writing, it might be easy to draw some diagrams to see the relationship.
