Question
Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be a continuous function such that for all open sets $U$ in $\mathbb{R}$, $f(U)$ is open. Prove that $f$ is injective.
My proof
Suppose $f$ is not injective. Then there exists $x, y\in \mathbb{R}$ such that $f(x) = f(y)$ but $x\neq y$. WLOG assume $x<y$. Then $d_{\mathbb{R}}(x,y) = |x-y|>0$. So $(x,y)$ is open and non-empty. Let this open set be $U$.
Suppose that, for all $z\in U$, $f(z) = f(x) = f(y)$. Then $f(U)$ is a singleton set, not open, a contradiction.
So suppose that there exists at least one $z\in U$ such that, WLOG, $f(z)>f(x)=f(y)$. Since $f$ is continuous, and $[x,y]$ compact, $f([x,y])$ compact, closed, (connected?) therefore there exists $\alpha\in[x,y]$ such that $f(\alpha) = \sup f([x,y])$ (connected?). By assumption $f(\alpha)\geq f(z)>f(x)=f(y)$, so clearly $\alpha\in U$. But since $f(\alpha)$ is an upper bound of $f(U)$, for all $\epsilon>0$, $(\alpha-\epsilon, \alpha + \epsilon)$ is not a subset of $f(U)$, despite $\alpha\in U$, so $f(U)$ not open, a contradiction. Other cases are handled similarly.
My questions
Not sure if I need connectedness (as in I know intervals are connected but I can't tell if it's crucial for the proof) or completeness of $\mathbb{R}$, and whether this proof is correct.