I am trying to prove this using the definition of continuity (and complements) where $f$ is continuous iff for every open set $U$, $f^{-1}(U)$ is also open. But I am uncertain about my proof when I try to write it formally. If somebody can present a formal proof, it will be really appreciated.
Thanks!