Rudin's PMA Theorem 11.33b Theorem 11.33b)

Suppose $f$ is bounded on $[a,b]$. Then $f \in \mathfrak{R}$ (Riemann Integrable) if and
  only if $f$ is continuous almost everywhere on $[a,b]$.

The structure of the proof proceeds as follows:
Construct a series of partitions $P_k$, each being a refinement of the previous partition and with adjacent points less than $\frac{1}{k}$ apart. Then if $x \notin \cup_k P_k$, then $L(x) = U(x)$ iff $f$ is continuous at $x$. ( $L_k(x)$ is the (lower) function that corresponds to the infinum of $f(x)$ in each of its intervals partitioned by $P_k$, and $L(x)$ is the limit of $L_k(x)$ as $k \to \infty$. For the upper function $U(x)$ the supremum is used)
Rudin then retrieves a result in the previous part of the proof, namely that $f \in \mathfrak{R}$ iff $L(x) = U(x)$ almost everywhere. 
Here is the part that I do not understand - Rudin concludes by saying:

Since the union of the sets $P_k$ is countable, its measure is $0$, and we conclude that $f$ is continuous almost everywhere on $[a,b]$ iff $L(x) = U(x)$ almost everywhere, hence iff $f \in \mathfrak{R}$.

I understand the two premises separately, but I don't see how they combine to give the conclusion of "iff $f \in \mathfrak{R}$". Can someone explain this?
 A: It helps to write out in set language. The assertion "if $x\not\in\cup_kP_k$, then $L(x)=U(x)$ iff $f$ is continuous at $x$" translates to:
$$
N^c\cap\{x: L(x)=U(x)\} = N^c\cap \{x: \text{$f$ is continuous at $x$}\}\tag1
$$
where for brevity we write $N:=\cup_kP_k$, a set of measure zero. Equivalently:
$$
N\cup\{x: L(x)\ne U(x)\} = N\cup \{x: \text{$f$ is discontinuous at $x$}\}\tag2
$$
The result Rudin retrieves is:

$
f\in{\mathfrak R}
$ if and only if $\{x: L(x)\ne U(x)\}$ has measure zero

Since $N$ has measure zero, the RHS is equivalent to:

$N \cup \{x: L(x)\ne U(x)\}$ has measure zero

and by (2) is equivalent to

$N \cup \{x: \text{$f$ is discontinuous at $x$}\}$ has measure zero

and, again since $N$ has measure zero, is equivalent to:

$\{x: \text{$f$ is discontinuous at $x$}\}$ has measure zero.

A: For necessity, Rudin's proof is based on results related to Lebesgue integration. In particular, the result that if $\int g = \int h$ and $g\leq h$, then $g=h$ a.s. Here is more or less Rudin's argument:
Choose partitions $\mathcal{P}_n\subset\mathcal{P}_{n+1}$ such that
$U(f,\mathcal{P}_n)-L(f,\mathcal{P}_n)<1/n$. For each partition $\mathcal{P}_n$, let $m_{n,k}=\inf\{f(t):t\in[t_{n,k-1},t_{n,k}]\}$ and 
$M_{n,k}=\sup\{f(t):t\in[t_{n,k-1},t_{n,k}]\}$.
Let $g_n$ and $h_n$ be defined by $g_n(a)=h_n(a)$; and $g_n(t)=m_{n,k}$, $h_n(t)=M_{n,k}$ on $t\in(t_{n,k-1},t_{n,k}]$.
Clearly,   $g_n\leq g_{n+1}\leq f\leq h_{n+1}\leq h_n$  on $[a,b]\setminus\mathcal{P}_n$,  and $\int_{[a,b]}g_n=L(f,\mathcal{P}_n)\leq U(f,\mathcal{P}_n)=\int_{[a,b]}h_n$. 
Dominated convergence  implies $\int_{[a,b]}g(x)dx=\int_{[a,b]}h(x)dx=A(f)$; Thus, since $g=\lim_ng_n\leq  f\leq \lim_nh_n=h$, then  $g=f=h$ a.s.
Let $\mathcal{D}=\{t\in[a,b]:g(t)<f(t)\}$. Then, $f$ is continuous at every point $x\notin\bigcup_n\mathcal{P}_n\cup \mathcal{D}$.
For sufficiency, I only sketch the proof. Decompose the set of discontinuities $D$ as the union of sets where the modulus of discontinuity is larger that say $\frac1n$, i.e.
$$D=\bigcup_n\{x\in [a,b]:\omega_f(x)\geq\frac1n\}$$
where $\omega_f(x)$ is the modulus of continuity of $f$ at $x$. If $\lambda(D)=0$ then all of $\lambda\{x:\omega_f(x)\geq\frac1n\}=0$
Then one may argue that for any $n$, there is $\delta_n>0$ such that whenever $I\subset[a,b]$ is a subinterval with $\lambda(I)<\delta$ and $I\cap D=\emptyset$, then $\sup\{|f(x)-f(y)|:x,y\in I\}\leq\frac1n$. Then use partitions that the subintervals that cover the set $D_n=\{x:\omega_f(x)\geq\frac1n\}$ have lengths that add up to something less than $\frac1n$ (this is possible since $\lambda(D_n)=0$) and the each of the remaining subintervals have length less than $\delta_n$. Then $U(f,P)-L(f,P)< (M-m+b-a)/n$, where $M=\sup f$ and $m=\inf f$. 
Not to change one book for another, but a full argument, using only the notion of a set of measure zero, can be found in the book of Apostol's Mathematical analysis, section 7.26.
