On the boundary of the upper half-plane $\mathbb{H}$ and a linear fractional transformation that preserves it

Let $f: \hat{\mathbb C}\rightarrow\hat{\mathbb C}; z\mapsto (az + b)/(cz + d)$ be a linear fractional transformation that preserves the upper half-plane $\mathbb{H} = \{z\in\mathbb C\mid \Im z > 0\}$. A textbook at hand says this:

Since $\{f(0), f(1), f(\infty)\} \subset \mathbb{R}\cup\{\infty\}$, $a,b,c,d\in\mathbb R$. Therefore, $f(\mathbb{R}\cup\{\infty\}) = \mathbb{R}\cup\{\infty\}$.

At first I thought why $\{f(0), f(1), f(\infty)\} \subset \mathbb{R}\cup\{\infty\}$ holds is that since $f$ preserves $\mathbb H$, $f$ also preserves the boundary of $\mathbb H$. But this is not the case, because the author of the textbook derives $f(\mathbb{R}\cup\{\infty\}) = \mathbb{R}\cup\{\infty\}$ from $\{f(0), f(1), f(\infty)\} \subset \mathbb{R}\cup\{\infty\}$.

So why can you say $\{f(0), f(1), f(\infty)\} \subset \mathbb{R}\cup\{\infty\}$ holds?

-

Your first thought was correct. Since you preserve $\mathbb{H}$, by continuity you preserve its boundary $\mathbb{R}\cup\{\infty\}$. Unless I'm very far off my game today, the textbook is backward. You first argue that $\mathbb{R}\cup\{\infty\}$ maps to itself, so that you know that $0,1,\infty$ map to real numbers.