Prob. 15, Chap. 4 in Baby Rudin: Every continuous open mapping of $\mathbb{R}$ into $\mathbb{R}$ is monotonic

Here is Prob. 15, Chap. 4 in the book Principles of Mathematical Analysis by Walter Rudin, 3rd edition:

Call a mapping of $X$ into $Y$ open if $f(V)$ is an open set in $Y$ whenever $V$ is an open set in $X$.

Prove that every continuous open mapping of $\mathbb{R}^1$ into $\mathbb{R}^1$ is monotonic.

My effort:

Suppose $f$ is a continuous open mapping of $\mathbb{R}^1$ into $\mathbb{R}^1$. If $f$ is not monotonic, then there exist real numbers $x$, $y$, and $z$ such that $$x < y < z,$$ and $$\mbox{ either } f(x) < f(y) \ \mbox{ and } \ f(y) > f(z), \ \ \mbox{ or } \ \ f(x) > f(y) \ \mbox{ and } \ f(y) < f(z).$$

Now as $f$ is continuous on the closed interval $[x, z]$ and as $[x, z]$ is a compact subset of $\mathbb{R}$, so the image $f\left( [x, z] \right)$ is also a compact --- and hence closed and bounded --- subset of $\mathbb{R}$.

Thus the set $f\left( [x, z] \right)$ has a maximum element $M$ and a minimum element $m$.

First, assume that $$x < y < z, \ \ f(x) < f(y), \ \mbox{ and } \ f(y) > f(z).$$ Then $$f(y) > \max \left\{ f(x), f(z) \right\}. \ \tag{1}$$

But in view of (1) above, we can conclude that the maximum $M$ of $f\left( [x, z] \right)$ is attained at some interior point $p$, say, of $[x, z]$.

Then we can conclude that the image set $f\left( (x, z ) \right)$ of the open set $(x, z)$ in the domain space $\mathbb{R}^1$ has a maximum element $M$ and therefore cannot be open in the codomain space $\mathbb{R}^1$; for no $\delta > 0$ can the open interval $( M-\delta, M+\delta)$ be contained in $f\left( (x, z ) \right)$, which gives rise to a contradiction.

So we assume that $$x < y < z, \ \ f(x) > f(y), \ \mbox{ and } \ f(y) < f(z).$$ Then $$f(y) < \min \left\{ f(x), f(z) \right\}. \ \tag{2}$$ Then the minimum $m$ of the set $f \left( [x, z] \right)$ is attained at some interior point $q$, say, of $[x, z]$, which implies that the image under $f$ of the open set $(x, z)$ fails to be open because this image set contains $m$ but fails to contain the open interval $(m-\delta, m+\delta)$ for any real number $\delta > 0$, which is a contradiction.

Hence every continuous open mapping $f$ of $\mathbb{R}^1$ into $\mathbb{R}^1$ is monotonic.

Is this proof correct? If so, then what about the presentation? Is the presentation lucid enough too? If not, then where does the problem lie?

Hint: Let $a<b$. Since $f(x)$ is continuous and open, then $$f((a,b))=(c,d)$$ for some $c<d$. Try to show $f({a,b})={c,d}$. From this, either $f(a)=c,f(b)=d$ or $f(a)=d,f(b)=c$. Namely $f(a)<f(b)$ or $f(a)>f(b)$.