Let $S$ be the unit circle with the usual topology and let $\mathbb{R}$ be equipped with the discrete topology, then consider $S \times \mathbb{R}$ with the product topology, and consider the map $f(x) = (x,x)$ from $S$ to $S \times \mathbb{R}$, where here we are identifying $S$ with, say, $[0,1)$.
Is this map $f$ continuous?
The preimage of any $U \times R$ under $f$ for $U$ open in $S$ and $R$ open in $\mathbb{R}$ (any subset) is just $U$ or $\emptyset$, which is open in $S$, so it seems that $f$ should be continuous.
On the other hand...
Consider a non-closed subset $B$ of $S$. We have that $B = f^{-1}(f(B))$, but $f(B)$ is closed since any converging sequence in $S \times \mathbb{R}$ must be eventually constant. So, if $f$ were continuous we would have $B$ is closed since it is the inverse image of a closed set under a continuous map, a contradiction.
Clearly there is a mistake somewhere, but where have I gone wrong? Is the map $f$ continuous or not?