Let $f:\mathbb{R}\to\mathbb{R}$ be continuous function with the additional property $$F\;\mbox{is a closed subset of }\mathbb{R}\;\iff f(F)\;\mbox{is a closed subset of}\;\mathbb{R}.$$
I would like to prove that $f$ is a surjective map.
(In fact it's an homeomorphism but I am interested to prove the surjectivity only)
I try using that as $\Bbb{R}$ is closed so that $f(\Bbb{R})$ is closed and connected subset of $\Bbb{R}$ so it's a closed interval. But not sure how to eliminate $[a,b]\;;(-\infty,b]\;;[a;\infty).$
Assume by way of contradiction that $f$ is not surjective, so that by connectedness, $f(\Bbb R)$ is bounded above and/or below.
Suppose it is bounded above, and let $b$ be its supremum. By closedness, $b$ is its maximum, so there exists $x\in\Bbb R$ such that $f(x)=b.$ Now, show that $f$ maps one of $(-\infty,x+1)$ and $(x-1,\infty)$ onto $f(\Bbb R),$ contradicting our closedness condition. We similarly obtain a contradiction if it is bounded below.