One can also give a direct proof. Suppose $f:[0,1]\to \Bbb R$ is Riemann integrable.
Lemma Suppose that for a partition $P$; $\displaystyle D(f,P)=\sum_{k=0}^n (M_k-m_k)\Delta x_k<\varepsilon$. Then $M_k-m_k<\varepsilon $ for some $k$.
Proof Else $\displaystyle\varepsilon =\sum_{k=0}^n \varepsilon\Delta x_k\geqslant \sum_{k=0}^n (M_k-m_k)\Delta x_k$, proving the contrapositive.
Obs More generally, we get $M_k-m_k<(b-a)\varepsilon$ if the interval of integration is $[a,b]$.
We proceed to the proof of your claim.
Notation For a set $S$, we denote $o(f,S)=\sup\limits_{t,t'\in S}|f(t)-f(t')|$.
With this lemma at hand, we may start rolling: take $\varepsilon =1$. We know there exists a partition $P_1=\{0=x_0,x_1,\ldots,x_n=1\}$ with $D(f,P_1)<1$, since $f$ is Riemann integrable. By the lemma, there is a subinterval $I_i=[x_{i-1},x_i]$ where $o(f,I_i)<1$. If $i\neq 1$ or $n$, let $K_1=I_i$. Else, pick $x_0<x_0'<x_1$ or $x_{n-1}<x_n'<x_n$, and replace this in the endpoints of $K_i$. Now $f$ is integrable over $K_1$, so there exists a partition $P_2$ for which the sum in $K_1$, $D(f,P_2)<\frac 1 2$, which gives some subinterval $K_2$ where $o(f,K_2)<\dfrac 1 2|K_1|<\dfrac 1 2 $, since $|K_1|<1$. Again, we replace endpoints if necessary. Since we're shrinking the domain, in any case the oscillation descreases, so we're safe. Inductively, we can construct a sequence of strictly nested closed bouned intervals $$K_1\supsetneq K_2\supsetneq K_2\supsetneq\cdots$$ where $o(f,K_i)<\frac 1 i$. By Cantor, there is $x_0\in\bigcap\limits_{j\geqslant 1} K_j$. I claim $f$ is continuous at $x_0$. (Proof?)
Now consider $[0,x_0],[x_0,1]$. Note that by construction $x_0\neq 0,1$, so repeating this on $[0,x_0]$ we obtain $x_1\neq x_0$ where $f$ is continuous, and so on. Using this, we may also show
Claim The set where $f$ is continuous is dense in $[0,1]$.
Let $P_n$ be the partition including $0,1$ and $q_1,...,q_n$. We denote this partition by $P_n=\{t_0=0,t_1,...t_n,t_{n+1}=1\}$. Moreover, let $s_i$ be the term in $\sum p_k$ corresponding to $t_i$ for $1\leq i\leq n$.
Observe that
$h(t_i)\geq \sum_{j=1}^is_j$ and
$h(t_i)+\sum_{j=i}^ns_j\leq 1$
$\implies h(t_i) \leq 1-\sum_{j=i}^ns_j$
We can now bound the upper and lower Riemann sums.
$$L(f,P_n)\geq \sum_{i=1}^nh(t_i)(t_{i+1}-t_i) $$$$\geq \sum_{i=1}^n\left((t_{i+1}-t_i)\sum_{j=1}^i s_j\right)=\sum_{i=1}^n(s_i-t_is_i)$$
This last sum is just a rearrangement of $\sum_{k=1}^np_k-p_kq_k$.
$$U(f,P_n)\leq \sum_{i=0}^nh(t_{i+1})(t_{i+1}-t_i)$$$$\leq \sum_{i=0}^n(t_{i+1}-t_i)(1-\sum_{j=i+1}^ns_j)$$$$=1- \sum_{i=0}^n\left((t_{i+1}-t_i)\sum_{j=i+1}^ns_j\right)$$$$ = 1-\sum_{i=1}^ns_it_i=1-\sum_{k=1}^np_kq_k.$$
Taking limits as $n\to\infty$, we find the desired integral to be $$\fbox{1-$\sum p_kq_k$}.$$
Best Answer
Apparently the codomain of $g$ includes $\infty$. That can in itself be okay; there are good topologies on the extended real line.
Your argument seems to lead to the the fact that there is a dense set of points $x$ where $g(x)=\infty$. However, that in itself does not make $g$ discontinuous everywhere -- as far as you have argued so far, there might be an entire interval somewhere where $g(x)=\infty$. Then $g$ would be perfectly continuous in the interior of such interval.
So you need an explicit argument that this is not the case. (One is suggested by the title of your question, but you should write it down explicitly ...)