If there exists a continuous non-constant map to the integers, then the space is not connected

Let X be a topological space. show that if there exists a continuous, non constant map from X to the integers with the discrete topology, then X is not connected.

So I know that connected subspaces of integers with the discrete topology are just points. Also the image of a connected space under a continuous map is connected.

Here is where my reasoining for the proof eludes me. If I take the inverse image of those points is it that I haven now created a separation in the inverse image thus showing that X is not connected? Or is it that since the image of a connected space under a continuous function is connected, but since this maps to a point, the function is therefore constant?

• If it's continuous, then the inverse image of any open set must be open. Does this help? Show a contradiction. – Euler....IS_ALIVE Oct 16 '14 at 3:51
• But since i was not given a specific topology for X how can i find a closed set? – dc3rd Oct 16 '14 at 3:57
• @dc3rd Open = Closed if you have the integers with the discrete topology – Aram Oct 16 '14 at 4:11

If you already know that the image of a connected set is connected, then you're done: if $f:X\to \mathbb{Z}$ is connected, then $f(X)$ is connected. The only connected subsets of $\mathbb{Z}$ are points, so $f(X)$ is a point, i.e. $f$ is constant.
Let $f$ be a non constant continuous function. It should suffice to prove it for two different points (Why?). Let $\{0,1\} = Im(f)$. Now $0$ and $1$ are open sets, and because $f$ is continuous we have that $f^{-1}(0)$ and $f^{-1}(1)$ are open and $f^{-1}(0) \cup f^{-1}(1) = X$, but $f^{-1}(0)\cap f^{-1}(1) = \emptyset$!