This question was already asked.
Let $ X \subset \mathbb{R}$ be a non-empty, open set and let $f: X \rightarrow \mathbb{R}$ be a continuous function.
Prove that the inverse image of an open set is open
Here is the proof by DiegoMath.
Take $x_0\in f^{-1}(M)$, then $f(x_0)\in M$.
Since $M$ is open, there exists $r>0$ such that $B(f(x_0),r)\subset M$.
Now, choose any $0<\varepsilon\leq r$, since $f$ is continuous, there exists $\delta>0$ such that $f(x)\in B(f(x_0),\epsilon)$ whenever $x\in B(x_0,\delta)$.
Note that if $x\in B(x_0,\delta)$, then $f(x)\in B(f(x_0),\varepsilon)\subset M$, thus $f(x)\in M$, moreover, $x\in f^{-1}(M)$, thus $B(x_0,\delta)\subset f^{-1}(M)$, then $f^{-1}(M)$ is open.
I do not understand why showing that $B(x_0,\delta)\subset f^{-1}(M)$, is sufficient to show that $f^{-1}(M)$ is open . Moreover, is it really true that $f(x)\in M$ for any x?