I am trying to prove the following statement, but I have been stuck for a while and I am looking for an **hint** about how to prove it:

"Suppose $B\subset\mathbb{R}$ and $f:B\to\mathbb{R}$ is an increasing function. Prove that $f$ is continuous at every element of $B$ except for a countable subset of $B$."

What I have tried to do:

Since I wasn't able to tackle the original statement I tried by assuming that $B$ is also a Borel set so as to exploit in some way the fact that $f$ must then be a Borel measurable function. Then if $D:=\{x\in B: f\text{ is not continuous at }x\}$ and $C$ is a Borel set we have that $f^{-1}(C)$ is a Borel set and $f^{-1}(C)=(f^{-1}(C)\cap D)\cup (f^{-1}(C)\cap B\setminus D)$ and at this point I tried to go on by contradiction, assuming that $D$ is uncountable and tried to show that $(f^{-1}(C)\cap D)\cup (f^{-1}(C)\cap B\setminus D)$ is not a Borel set but I haven't succeeded so I would greatly appreciate any **hint or comment or explanation that could nudge me towards a more fruitful approach, thanks**.

---

EDIT (Proof): Let $D:=\{x\in B:f\text{ is not continuous at }x\}$: since $f$ is monotone (increasing) [it can only have jump discontinuities](https://math.stackexchange.com/q/4171854) so if $d\in D$ then $I\_d:=(\lim\limits\_{x \to d^-,\ x\in B\\}f(x),\lim\limits\_{x \to d^+,\ x\in B}f(x))=(\sup\_{x<d,\ x\in B}f(x),\inf\_{x>d,\ x\in B} f(x))$ is a non-empty interval in $\mathbb{R}$ hence there must be a rational number $q\_d$ in it which we can choose and since $I\_d\cap I\_{d'}=\emptyset$ for $d\neq d'$\* this rational number is also unique so we can define an injective function $g:D\to\mathbb{Q}, g(d):=q\_d$. Thus $\#(D)\leq \#(\mathbb{Q})=\#(\mathbb{N})$ ie the set of points at which $f$ is discontinuous is (at most) countable, as desired. $\square$

---

(\*) Suppose $I\_d\cap I\_{d'}\neq\emptyset$ for some $d\neq d'$ (we can suppose wlog that $d<d'$): then there must be $y\in I\_d\cap I\_{d'}$ so $\sup\_{x<d,\ x\in B}f(x)<y<\inf\_{x>d,\ x\in B}f(x)$ and $\sup\_{x<d',\ x\in B}f(x)<y<\inf\_{x>d',\ x\in B}f(x)$ which implies (since $d\leq d'\Rightarrow \inf\_{x>d,\ x\in B}f(x)\leq \sup\_{x<d', x\in B}f(x)$) that $y<y$, contradiction.