I am reading "Measure, Integration & Real Analysis" by Sheldon Axler.
The following exercise is Exercise 17 on p.39 in Exercises 2B in this book.
Exercise 17
Suppose $X$ is a Borel subset of $\mathbb{R}$ and $f:X\to\mathbb{R}$ is a function such that $\{x\in X:f\text{ is not continous at }x\}$ is a countable set. Prove $f$ is a Borel measurable function.
My proof:
To prove that $f$ is Borel measurable, fix $a\in\mathbb{R}$.
Let $D:=\{x\in X:f\text{ is not continous at }x\}$.
Since $D$ is countable, we can write $D=\{x_1,x_2,\dots\}$.
If $x\in X\setminus D$ and $f(x)>a$, then (by the continuity of $f$) there exists $\delta_x>0$ such that $f(y)>a$ for all $y\in (x-\delta_x,x+\delta_x)\cap X$. Thus $$f^{-1}((a,\infty))=\left(\left(\bigcup_{x\in f^{-1}((a,\infty))\cap(X\setminus D)} (x-\delta_x,x+\delta_x)\right)\cap X\right)\cup\left(f^{-1}((a,\infty))\cap D\right).$$
$\bigcup_{x\in f^{-1}((a,\infty))\cap(X\setminus D)} (x-\delta_x,x+\delta_x)$ is an open subset of $\mathbb{R}$.
So, this set is a Borel subset of $\mathbb{R}$.
So, $\left(\bigcup_{x\in f^{-1}((a,\infty))\cap(X\setminus D)} (x-\delta_x,x+\delta_x)\right)\cap X$ is a Borel subset of $\mathbb{R}$.
$f^{-1}((a,\infty))\cap D$ is countable since $D$ is countable.
So, $f^{-1}((a,\infty))\cap D$ is a Borel subset of $\mathbb{R}$.
So, $f^{-1}((a,\infty))=\left(\left(\bigcup_{x\in f^{-1}((a,\infty))\cap(X\setminus D)} (x-\delta_x,x+\delta_x)\right)\cap X\right)\cup\left(f^{-1}((a,\infty))\cap D\right)$ is a Borel subset of $\mathbb{R}$.
So, $f$ is a Borel measurable function.
Is my proof ok?