Let $f:E \to \mathbb{R}$ be continuous in its domain, where $E \subseteq \mathbb{R}$ is a closed set which is not bounded above and not bounded below.
Let $i: \mathbb{R} \to [-\infty,\infty]$ by $i(x)=\inf\{y \in E:x \leq y\}$.
Let $s: \mathbb{R} \to [-\infty,\infty]$ by $s(x)=\sup\{y \in E:y \leq x\}$.
Let $g:\mathbb{R}\to \mathbb{R}$ by $g(x)= \begin{cases} f(x),\space x\in E \\ f(s(x))+\frac{f(i(x))-f(s(x))} {i(x)-s(x)}(x-s(x)), \space x\in E^c \end{cases}$
It's easy to show that $g$ is continuous at points $x_0 \in E^c$ and at points $x_0 \in int(E)$, since $g$ is identically equal to either a linear function or $f$ in small intervals. I want to show that $g$ is also continuous on $E-int(E)$.
Here is what I have tried: Let $x_0 \in E-int(E)$. We can't have both $\exists r>0[(x_0,x_0+r) \subseteq E]$ and $\exists r>0[(x_0-r,x_0) \subseteq E]$, so assume WLOG $\forall r>0[(x_0,x_0+r) \nsubseteq E]$. We see that $f(x_0)=g(x_0)$.
Let $ε>0$. We want to show $\exists δ>0 \forall x \in(x_0-δ,x_0+δ)[|g(x)-f(x_0)|<ε]$.
It's obvious that $\exists δ>0 \forall x \in(x_0-δ,x_0+δ) \cap E[|g(x)-f(x_0)|<ε]$ by the continuity of $f$, therefore:
It remains to show $\exists δ>0 \forall x \in(x_0-δ,x_0+δ) \cap E^c[|g(x)-f(x_0)|<ε]$.
I am stumped on what delta to choose for the highlighted part. I suspect that the solution will have something to do with writing $g(x)=f(s(x))+\frac{f(i(x))-f(s(x))} {i(x)-s(x)}(x-s(x))$ and showing that it is "close" to $f(x_0)$, but I just don't see how to do it formally.