Is a continuous real-valued function with an almost everywhere continuous derivative necessarily differentiable on $\mathbb{R}$? Setting:
Let $a\in \mathbb{R}$, and let $f$ be a function which is continuous on $\mathbb{R}$, differentiable on $(\infty,a)\cup (a,\infty)$, and has the property that $\lim_{x\to a^{-}}f'(x) = \lim_{x\to a^{+}}f'(x) = L$ for some $L\in\mathbb{R}$.
Question:
Does it automatically follow that $f$ is differentiable at $a\in \mathbb{R}$?
My intuition wants to say yes since we are placing such strong conditions on $f$, and if I were going to try to prove this I would pursue the following logic:
Argument:
\begin{align*}
f'(a) &= \lim_{h\to 0}\frac{f(a+h) - f(a)}{h}\\
&= \lim_{h\to 0}\left[\lim_{x\to a^{-}}\frac{f(x+h) - f(x)}{h}\right]\text{using continuity of} f \text{at }a\\
&= \color{red}{\lim_{x\to a^{-}}\left[\lim_{h\to 0}\frac{f(x+h) - f(x)}{h}\right]}\\
&= \lim_{x\to a^{-}}f'(x)\\
&= L
\end{align*}
or using essentially the same argument from the other side.....
\begin{align*}
f'(a) &= \lim_{h\to 0}\frac{f(a+h) - f(a)}{h}\\
&= \lim_{h\to 0}\left[\lim_{x\to a^{+}}\frac{f(x+h) - f(x)}{h}\right]\text{using continuity of} f \text{at }a\\
&= \color{blue}{\lim_{x\to a^{+}}\left[\lim_{h\to 0}\frac{f(x+h) - f(x)}{h}\right]}\\
&= \lim_{x\to a^{+}}f'(x)\\
&= L
\end{align*}
But the steps that I've outlined in red and blue correspond to geniune gaps in my argument.  We cannot always interchange such limits without caution, but perhaps due to the strong assumptions on $f$ we can in this case.
Is there an example of a function $f$ (of course, satisfying the conditions give above) for which this logic fails?
If not, how can I fix my argument?
 A: For $h>0$, 
\begin{align*}
\dfrac{f(a+h)-f(a)}{h}-L&=\lim_{\eta\rightarrow 0^{+}}\dfrac{f(a+h)-f(a+\eta)}{h}-L\\
&=\lim_{\eta\rightarrow 0^{+}}\dfrac{1}{h}\int_{a+\eta}^{a+h}f'(t)dt-L\\
&=\lim_{\eta\rightarrow 0^{+}}\dfrac{1}{h}\left(\int_{a+\eta}^{a+h}f'(t)dt-\int_{a}^{a+h}Ldt\right)\\
&=\lim_{\eta\rightarrow 0^{+}}\dfrac{1}{h}\left(\int_{a+\eta}^{a+h}(f'(t)-L)dt-\int_{a}^{a+\eta}Ldt\right)\\
&=\lim_{\eta\rightarrow 0^{+}}\dfrac{1}{h}\int_{a+\eta}^{a+h}(f'(t)-L)dt.
\end{align*}
Now given $\epsilon>0$, there is a $\delta>0$ such that for $a<t<a+\delta$, $|f'(t)-L|<\epsilon$, so with $h<\delta$, we have
\begin{align*}
-\dfrac{h-\eta}{h}\cdot\epsilon\leq\dfrac{1}{h}\int_{a+\eta}^{a+h}(f'(t)-L)dt\leq\dfrac{h-\eta}{h}\cdot\epsilon.
\end{align*}
Taking $\eta\rightarrow 0^{+}$ we have
\begin{align*}
-\epsilon\leq\dfrac{f(a+h)-f(a)}{h}-L\leq\epsilon,
\end{align*}
so
\begin{align*}
\left|\dfrac{f(a+h)-f(a)}{h}-L\right|\leq\epsilon,
\end{align*}
and we are done.
A: Switching of limit has to be justified. Instead of this use MVT: for $h>0$ MVT theorem shows that $f(x+h)-f(x)=hf'(\xi)$ for  some $\xi \in (x,x+h)$ and $f'(\xi) \to L$. Can you use this hint to give a new proof?
