I've come across this problem in my notes:
$\forall \sigma, \delta \geq 0:\ \exists \varphi$ continuous s.t. $\mu \{x: f(x)-\varphi(x)\geq \sigma\} \leq \delta$
Find $N: \frac{2M}{N} \leq \sigma$
let $E_i=\{x: \frac{(i-1)M}{N} \leq f(x) \leq \frac{iM}{N}\}\ i=1-N,..., N$
for each $E_i$ find $F_i \subset E_i:\ \mu F_i \leq \mu E_i- \frac{\delta}{4n}$
$F=\bigcup_{i=1}^N F_i$ where $\{F_i\}_{i=1-N}^N$ are disjoint closed sets
$\mu([a,b] \backslash F)\leq \frac{\delta}{2}$
we define $\varphi|_{F_i}=\frac{iM}{N},$ I understand that $\varphi$ is continuous on $F$. But how can we argue it is continuous on the whole interval $[a,b]$. What do we do about the endpoints?