Here is Theorem 7.34 (the Second Fundamental Theorem of Integral Calculus), in Chapter 7, in the book Mathematical Analysis - A Modern Approach To Advanced Calculus by Tom M. Apostol, 2nd edition:
Assume that $f$ is a real-valued, Riemann-integrable function on $[a, b]$. Let $g$ be a function defined on $[a, b]$ such that the derivative $g^\prime$ exists in $(a, b)$ and has the value $$ g^\prime (x) = f(x) \ \mbox{ for every $x$ in $(a, b)$}. $$ At the ednpoints assume that $g(a+)$ and $g(b-)$ exist and satisfy $$ g(a) - g(a+) = g(b) - g(b-).$$ Then we have $$ \int_a^b f(x) \, dx = \int_a^b g^\prime(x)\, dx = g(b) - g(a). $$
And, here is Apostol's proof of this theorem:
For every partition of $[a, b]$, we can write $$ g(b) - g(a) = \sum_{k=1}^n \left[ g \left( x_k \right) - g \left( x_{k-1} \right) \right] = \sum_{k=1}^n g^\prime \left( t_k \right) \Delta x_k = \sum_{k=1}^n f \left( t_k \right) \Delta x_k, $$ where $t_k$ is a point in $\left( x_{k-1}, x_k \right)$ determined by the Mean Value Theorem of differential calculus. But, for a given $\varepsilon > 0$, the partition can be taken so fine that $$ \left\lvert g(b) - g(a) - \int_a^b f(x) \, dx \right\rvert = \left\lvert \sum_{k=1}^n f \left( t_k \right) \Delta x_k - \int_a^b f(x) \, dx \right\rvert < \varepsilon, $$ and this proves the theorem.
Although I understand the statement as well as the proof of the Second Fundamental Theorem of Integral Calculus as given by Apostol, there is one catch.
What is the point of the very last equality in the statement of the theorem? For the Mean Value Theorem of Differential Calculus to be applicable, it should suffice for the function $g$ to be either continuous from the left at $a$ and from the right at $b$, or for the one sided limits $g(a+)$ and $g(b-)$ to exist as finite values.