Eliminating all removable discontinuities Recently I've been reading the Spivak's calculus textbook and got quite stuck on proving that if a function $$f:\mathbb{R}\to\mathbb{R}$$ has only removable discontinuities then $$g(x)=\lim_{y\to x} f(y)$$ is continuous.
I've tried using the $\varepsilon$-$\delta$ definition and the triangle inequality, but then it still remains to prove that certain values of $\delta$ cover the whole real line and it doesn't seem to be necessarily true. There is maybe a way to make the $\delta$ larger and finish it that way, but it seems to be quite ugly. So, I'm interested to hear whether there are other approaches, or better ways to finish using the approach above.
Edit: On the internet I've found another proof using the identity:
$$\lim_{b\to a} \lim_{c\to b} f(c) = \lim_{c\to a} f(c)$$
but I don't see how to prove it easily using the $\varepsilon$-$\delta$ definition. It immediately follows from the continuity of $$g(x)= \lim_{y\to x} f(y)$$ but is it possible to prove it without it?
 A: Let's use this definition of a removable singularity (from StinkingBishop's answer):

$f$ has a removable discontinuity at $a$ iff $\lim_{x \to a}f(x)$ exists but $\lim_{x \to a}f(x) \neq f(a)$.

Since all of the discontinuities of $f$ are removable, $\lim_{x \to a} f(x)$ exists for all $a \in \mathbb R$.
(If $f$ is continuous at $a$, then $\lim_{x \to a}f(x)$ exists and $\lim_{x \to a}f(x) = f(a)$. If $f$ has a removable discontinuity at $a$, then $\lim_{x \to a}f(x)$ exists but $\lim_{x \to a}f(x) \neq f(a)$.)
This means that it makes sense to define a function $g(x) := \lim_{y \to x} f(y)$.
Claim: For all $a \in \mathbb R$, $\lim_{x \to a} g(x) = g(a)$. (This proves that $g$ is continuous everywhere.)
Proof: Fix an $a \in \mathbb R$. Fix an $\epsilon > 0$. Since $\lim_{x \to a} f(x) = g(a)$, there exists a $\delta > 0$ such that $$x \in (a - \delta, a) \cup (a, a + \delta) \implies f(x) \in \left( g(a) - \tfrac 1 2 \epsilon, g(a) + \tfrac 1 2 \epsilon \right) \subset \left[ g(a) - \tfrac 1 2 \epsilon, g(a) + \tfrac 1 2 \epsilon \right].$$
But then,
$$x \in (a - \delta, a) \cup (a, a + \delta) \implies g(x) = \lim_{y \to x} f(y) \in \left[ g(a) - \tfrac 1 2 \epsilon, g(a) + \tfrac 1 2 \epsilon \right] \subset \left( g(a) - \epsilon, g(a) + \epsilon \right).$$
[To spell this out, if $x \in (a - \delta, a) \cup (a, a + \delta)$, then there exists an open neighbourhood $U$ of $x$ such that $f(y) \in \left[ g(a) - \tfrac 1 2 \epsilon, g(a) + \tfrac 1 2 \epsilon \right]$ for all $y \in U$. Hence $\lim_{y \to x} f(y) \in \left[ g(a) - \tfrac 1 2 \epsilon, g(a) + \tfrac 1 2 \epsilon \right]$.]
This shows that $\lim_{x \to a} g(x) = g(a)$.
A: Removable discontinuity of a function $f$ at a point $a$, means $\lim_{x\to a} f(x) $ exist finitely, but doesn't equal the functional value $f(a)$.
So, whenever , $\lim_{x\to a} f(x) = f(a) $, then function becomes continuous at $a$.
For example, take $f(x) =
\begin{cases}
2,  & \text{if $x=1$} \\
x, & \text{if $x\neq 1 $}
\end{cases}
$
Clearly here, $\lim_{x\to 1} f(x) = 1 \neq 2 = f(1) $
Also, using $\epsilon-\delta$ definition through this example,
you can see easily that , if we choose ,$\epsilon=\frac{1}{2}$, then for any $\delta > 0 $ , $|f(x)-f(1)|> \frac{1}{2} $ for some $x\in (1-\delta,1+\delta) $.
But if we take the function $f(x)=x $ on $\mathbb{R}$ ,
Then , $\lim_{x\to 1} f(x) = 1 = f(1) $
Edit: suppose $f$ has removable discontinuity on $\{r_{i}\}_{i\in \mathbb{N}}$
Then define , $g(x) =
\begin{cases}
\lim_{x\to r_{i}} f(x),  & \text{if $x=r_{i}$,$ i\in \mathbb{N}$} \\
f(x), & \text{otherwise}
\end{cases}
$
Then , as $f$ is continuous on whole $\mathbb{R}$ except $\{r_{i}\}_{i\in \mathbb{N}}$.
We check continuity of $g$ on  $\{r_{i}\}_{i\in \mathbb{N}}$.
As for each $r_i$ ,it is easily get that, as for any $\epsilon>0$ there exist a $\delta>0$ such that $|x-r_i|<\delta $
$\implies |f(x)-\lim_{x\to r_{i}} f(x)| < \epsilon(\text{limit of $f(x)$ exists at each $r_i$}) $
$\implies |g(x)-g(r_{i})| < \epsilon $
