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?
To see that $f$ is not continuous, observe that $f[S]$ is a discrete subset of $S\times\Bbb R$. To see this, let $x\in S$, where I identify $S$ with $[0,1)$; then $f(x)=\langle x,x\rangle$, so $S\times\{x\}$ is an open nbhd of $f(x)$ that contains no other point of $f[S]$. (In fact the discrete subsets of $S\times\Bbb R$ are precisely those $A\subseteq S\times\Bbb R$ with the property that $A\cap(S\times\{x\})$ is finite for each $x\in\Bbb R$.) Since $S$ is not a discrete space, $f$ cannot be continuous.