Integrability of a function $g$ that is different at $n$ points from $f$ Riemann integrable I have proved the following statement and I would like to know if I have made any mistakes:
"Suppose $f:[a,b]\to\mathbb{R}$ is Riemann integrable. Suppose $g:[a,b]\to\mathbb{R}$ is a function such that $g(x)=f(x)$ for all except finitely many $x\in [a,b]$. Prove that $g$ is Riemann integrable on $[a,b]$ and $\int_{a}^{b}g=\int_{a}^{b}f$."
My proof:
Let $d_1,\dots, d_n$ be the points such that $g(d_i)\neq f(d_i),\ 1\leq i\leq n$.
Let $\varepsilon>0$ and $P=a=x_0<x_1<\dots<x_N=b$ a partition of $[a,b]$ such that $x_j-x_{j-1}<\frac{\varepsilon}{N(\sup_{[a,b]}g-\inf_{[a,b]}g +1)}$: then $$U(g,P,[a,b])-L(g,P,[a,b])=\sum_{j=1}^{N}(x_j-x_{j-1})(\sup_{[x_{j-1},x_j]}g-\inf_{[x_{j-1},x_j]}g)<\sum_{j=1}^{N}\frac{\varepsilon}{N}=N\frac{\varepsilon}{N}=\varepsilon$$ so we have shown that for any $\varepsilon>0$ there exists a partition P such that $U(g,P,[a,b])-L(g,P,[a,b])<\varepsilon$ so $g$ is Riemann integrable, i.e. $U(g,[a,b])=L(g,[a,b])=\int_{a}^{b}g$.
Also, since $f$ and $g$ coincide in every interval where there is not a $d$-point, and there are at most $n$ such intervals which we label $[k_{j-1},k_j]\ 1\leq j\leq n$, and $\sup_B f-\inf_B g \leq \sup_A f-\inf_A g$ if $B\subset A$ (in such a case $\inf_B f\geq \inf_A f $ and $\sup_B f\leq \sup_A f$) we have $$U(f,[a,b])-L(g,[a,b])\leq U(f,P,[a,b])-L(g,P,[a,b])\leq (x_{k_1}-{x_{k_1-1}})(\sup_{[x_{k_1-1},{x_{k_1}}]}f-\inf_{[x_{k_1-1},x_{k_1}]}g)+\dots+(x_{k_n}-x_{k_n-1})(\sup_{[x_{k_n-1},{x_{k_n}}]}f-\inf_{[x_{k_n-1},{x_{k_n}}]}g)<\frac{\varepsilon}{N(\sup_{[a,b]}g-\inf_{[a,b]}g +1)}(\sup_{[a,b]}g-\inf_{[a,b]}g) + \dots + \frac{\varepsilon}{N(\sup_{[a,b]}g-\inf_{[a,b]}g +1)}(\sup_{[a,b]}g-\inf_{[a,b]}g)<\frac{\varepsilon}{N}+\dots +\frac{\varepsilon}{N}=\varepsilon$$ so we can also conclude that $U(f,[a,b])=L(g,[a,b])$ which (since $f$ Riemann integrable means $\int_{a}^{b}f=U(f,[a,b])=L(f,[a,b])$) implies  $\int_{a}^{b}f=\int_{a}^{b}g$, as desired.
 A: Consider the function $h:[a,b]\to\mathbb{R}, h=f-g$ i.e. $h(x):=f(x)-g(x)$ for all $x\in [a,b]$. Then $h$ is $0$ except at a finite number $N$ of points, namely those where $f$ and $g$ differ: let $d_1,\dots, d_N$ denote those points.
Let $\varepsilon>0$, $H:=\max\{|h(d_i)|:1\leq i\leq n\}$, take $n>\frac{N(b-a)H}{\varepsilon}$ and let $P$ be the equally spaced partition $a = x_0, x_1\dots, x_n = b$ of $[a, b]$ with $x_j−x_{j−1} =\frac{b−a}{n}$ for each $j = 1,\dots,n$.
Then $U(h,P,[a,b])=\sum_{j=1}^{n}(x_j-x_{j-1})\sup_{[x_{j-1},x_j]}h\leq\frac{N(b-a)H}{n}$ and $L(h,P,[a,b])=\sum_{j=1}^{n}(x_j-x_{j-1})\inf_{[x_{j-1},x_j]}h=0$ so $U(h,P,[a,b])-L(h,P,[a,b])\leq\frac{N(b-a)H}{n}-0\leq\frac{N(b-a)H}{n}<\varepsilon$. Since $\varepsilon>0$ was chosen arbitrarily this implies that $h$ is integrable; hence $-h$ is integrable too and so is $g=f+(-h)=f-h$.
Also, $\int_{a}^{b}h=\sup_P L(h,P,[a,b])=\sup_P 0=0$, so $\int_{a}^{b}g=\int_{a}^{b}(f+(-h))=\int_{a}^{b}f+\int_{a}^{b}(-h)=\int_{a}^{b}f-\int_{a}^{b}h=\int_{a}^{b}f.$ $\square$
