Proof if $f$ is continuous then the preimage is closed. I want to show that if $f: \mathbb{R}\to\mathbb{R}$ is continuous then $f^{-1}(l) = \{x\in\mathbb{R}|f(x) = l\}$ is closed.
I am not sure of my proof as I feel like I am missing a step:
I decided to use sequential continuity and consider a convergent sequence $(x_n)\subset f^{-1}(l)$.
By sequential continuity if $x_n \to L \implies f(x_n) \to f(L) = L'$
I want to say that I am now done - but I think I need to prove that $L \in f^{-1}(l)$, or $L' \in Imf$.
[Note] : As Robert mentioned, it is easier to show that continuity implies inverse of an open set is open which I will use as a Lemma.

Lemma $(1)$ : Consider $(X,d_{X})$ and $(Y,d_{Y})$ metric spaces and let $f : X\longrightarrow Y$. We claim that $f$ is continuous in $X$ if and only if for every open set $G\subseteq Y$, $f^{-1}(G)$ is open in $X$.

Proof :
$(\implies)$ :
Let $G$ be open in $Y$, we have to show that $f^{-1}(G)$ is open in $X$. Let $x_{0}\in f^{-1}(G)\implies f(x)\in G$ and since $G$ is open, then $f(x_{0})$ is an interior point of $G$ that is to say $\exists\varepsilon&gt;0$ such that $N_{\varepsilon}(f(x_{0}))\subseteq G$. By continuity of $f$ at $x_{0}$, $\exists\delta&gt;0$ such that $\forall x\in N_{\delta}(x_{0})\implies f(x)\in N_{\varepsilon}(f(x_{0}))$. We now show that $x\in f^{-1}(G)$, notice that :
\begin{align*}
\text{If}\;x\in N_{\delta}(x_{0})&amp;\implies f(x)\in N_{\varepsilon}(f(x_{0}))\subseteq G \\
&amp;\implies x\in f^{-1}(G),\;\forall x\in N_{\delta}(x_{0})\\
&amp;\implies N_{\delta}(x_{0})\subseteq f^{-1}(G)
\end{align*}
Hence, $x_{0}$ is an interior point of $f^{-1}(G)$ implying that $f^{-1}(G)$ is open in $X$.
$(\impliedby)$ :
We have that $\forall G\subseteq Y$ open, we have that $f^{-1}(G)$ is open in $X$. Let $x_{0}\in X$, we want to show that $f$ is continuous at $x_{0}$. Let $N_{\varepsilon}(f(x_{0}))$ be a neighborhood in $Y$ with $\varepsilon&gt;0$, then since $N_{\varepsilon}(f(x_{0}))$ is open in $Y$, then $f^{-1}(N_{\varepsilon}(f(x_{0}))$ is open in $X$. Now $x_{0}\in f^{-1}(N_{\varepsilon}(f(x_{0}))$ because $f(x_{0})\in N_{\varepsilon}(f(x_{0}))$. Therefore, $x_{0}$ is an interior point of $f^{-1}(N_{\varepsilon}(f(x_{0}))$ which means there exist $\delta&gt;0$ such that $N_{\delta}(x_{0})\subseteq f^{-1}(N_{\varepsilon}(f(x_{0}))$. Therefore, $\forall x\in N_{\delta}(x_{0})$ we have that $x\in f^{-1}(N_{\varepsilon}(f(x_{0}))\implies f(x)\in N_{\varepsilon}(f(x_{0}))$. Hence, $f$ is continuous at $x_{0}$.

Corollary : Consider $(X,d_{X})$ and $(Y,d_{Y})$ metric spaces and let $f : X\longrightarrow Y$. We claim that for every open set $G\subseteq Y$, we have that $f^{-1}(G)$ is open in $X$ if and only if for every closed set $F\subseteq Y$, we have $f^{-1}(F)$ is closed in $X$

Proof : The proof is trivial since it follows from the fact that $f^{-1}(E^{c})=(f^{-1}(E))^{c}$. Thus, if $f : X\longrightarrow Y$ is continuous and $F\subseteq Y$ is closed, then $F^{c}$ is open which implies $f^{-1}(F^{c})$ is open which means $(f^{-1}(F))^{c}$ is open by the $\text{(Lemma)}$ and thus $f^{-1}(F)$ is closed. The reverse implication also follows from that basis.
I think it's easiest to show that $U= \Bbb R \setminus f^{-1}(l)$ is open.  Assume $f(x) = y \neq l$.  Choose $\varepsilon= \vert y - l \vert$.  Then because $f$ is continuous $\exists \delta \gt 0$ such that $\vert z - x \vert \lt \delta \Rightarrow \vert f(z)-f(x) \vert = \vert f(z)-y \vert \lt \varepsilon= \vert y - l \vert$, which means $f(z) \neq l$.  Thus, $\{ z \in \Bbb R \mid \vert z-x \vert \lt \delta \}$ is an open set containing $y$ that is contained in $U$, so $y$ is in the interior of $U$.  But $y \in U$ was arbitrary so $U$ is open.