Converse of Intermediate Value Theorem with additional assumptions Consider the following partial converse of the Intermediate Value Theorem:
Let $f: \mathbb{R} \to \mathbb{R}$ such that $f$ maps any closed interval to a closed interval and such that the pre-image of any singleton $\{x\}$ is closed. Then $f$ is continuous. 

A brief outline of my proof:
-Suppose $f$ is discontinuous at $a$, i.e: 
$\exists \delta >0:\forall \epsilon>0 \exists x:|x-a|<\epsilon,|f(x)-f(a)| \ge\delta$
-We may WLOG assume that $\forall \epsilon>0 \exists x:|x-a|<\epsilon,f(x)\ge f(a)+\delta$
-Since $f([a-\epsilon,a+\epsilon])$ is an interval containing $f(a)$ and some $f(x) \ge f(a)+\delta$, it must contain $f(a)+\delta$.
-Hence we can find a sequence $x_n$ which has limit $a$ and for which $\forall n \in \mathbb{N}$, $f(x_n)=f(a)+\delta$.
-Since $f^{-1}(f(a)+\delta)$ is closed, it must contain the limit point $a$, which implies $\delta=0$, a contradiction.

The proof looks good to me except that I have never used the assumption that $f$ maps closed intervals to closed intervals. 
So my question is, is there a flaw in the proof or is this assumption unnecessary?
 A: There may be one fairly small oversight in your argument, depending on just what the WLOG hides. [Added: It turns out that it hides a valid argument; see the comments below.] You can’t guarantee that there’s an $x\in[a-\epsilon,a+\epsilon]$ such that $f(x)>f(a)+\delta$: you can guarantee only that there is an $x\in[a-\epsilon,a+\epsilon]$ such that $|f(x)-f(a)|\ge\delta$, i.e., either $f(x)\ge f(a)+\delta$ or $f(x)\le f(a)-\delta$. Then you can use the interval-preserving property of $f$ to conclude that for each $n\in\Bbb Z^+$ there is an $x_n$ such that $|x_n-a|<\frac1n$ and $f(x_n)\in\{f(a)-\delta,f(a)+\delta\}$. Then, finally, there must be a subsequence $\langle x_{n_k}:k\in\Bbb Z^+\rangle$ on which $f$ is constant, either at $f(a)-\delta$ or at $f(a)+\delta$. Whichever it is, the rest of your argument still goes through.
The argument requires only that $f$ map closed intervals to intervals. Of course since $f$ then turns out to be continuous, we can conclude that in fact it must map bounded closed intervals to closed intervals.
