I am trying to prove that a function $f :\mathbb{R} \to \mathbb{R}$ is continuous iff for every open set $U \subset \mathbb{R}$, the preimage $f^{-1}(U) = \{x\in\mathbb{R}|f(x)\in U\}$ is open.
To prove the backwards implication I have that$$\forall x\in f^{-1}(U), \exists\delta>0, (x-\delta,x+\delta)\subset f^{-1}(U)$$^ from the definition of an open set. $$(x-\delta,x+\delta)\subset f^{-1}(U)$$ and then applying $f$ $$(f(x+\delta),f(x-\delta))\subset U$$
So $f$ hits all the points in that interval, can I then say it is continuous over that interval? Or is my method of proof completely wrong.