(Proof clarification): Continuous functions on R must be Lebesgue measurable I came across this proof that continuous functions on $\textbf{R}$ must be Lebesgue measurable (see Corollary 2.3.1, which I've written out (inexactly) below underneath the link): 
http://www.applebaum.staff.shef.ac.uk/Ch2MeasFn.pdf 
Let $f : \textbf{R} \to \textbf{R}$ be continuous and O be an arbitrary open set in
R. Then, by the continuity of $f$,  $f^{-1}(O)$ is an open set in $\textbf{R}$. Then $f^{-1}(O)$
is in $\mathcal{B}(\textbf{R})$. Hence f is measurable.
But I still don't understand it. Namely, given a function $f$,  what if the image set of $f$ is a closed set? Then the preimage of $f$ wouldn't necessarily be open, would it? Am I mistaken?
 A: The proof goes as follows:

Theorem 2.2.2 (paraphrased). a function $f\colon S\to\mathbb{R}$ (where $(S, \Sigma)$ is a measurable space) is $\Sigma$-measurable if, and only if, $f^{-1}(O)\in\Sigma$ for every open $O\subseteq \mathbb{R}$.

Apply this theorem to the continuous function $f\colon\mathbb{R}\to\mathbb{R}$, where $(S,\Sigma)=(\mathbb{R},\mathcal{B}(\mathbb{R}))$. To show $f$ is Lebesgue measurable, it is therefore sufficient to consider only the open intervals $O\subseteq \mathbb{R}$. This is what the proof does: pick an arbitrary $O\subseteq \mathbb{R}$, show that $f^{-1}(O)\in\mathcal{B}(\mathbb{R})$. Since $O$ was arbitrary, this holds for all of them, so Theorem 2.2.2 gives the conclusion.
You do not need to consider closed sets, at any point.

Following your comment on the original post, you seem to be concerned by the following point in the proof of Proposition 2.3.1 in the document you linked (which is the part that argues that if $f$ is continuous, then $f^{-1}(O)$ is open for every open set $O$): what if $O\cap f(\mathbb{R})=\emptyset$, i.e. $f^{-1}(O)=\emptyset$?
Note that indeed their proof does not handle that. But it is then trivial to see that if $f^{-1}(O)=\emptyset$, since $\emptyset$ is indeed an open set, everything goes through.
