Continuity of a function to the integers

I am trying to prove that in $\mathbb{Z}$ with co-finite topology the only path-connected components are the singletons. (I reckon that) showing that

"if a function $\gamma : [0,1] \to \mathbb{Z}$, where $\mathbb{Z}$ has co-finite topology, is continuous then it is constant"

should do the trick.

However I am not sure this is true, let alone if this is a good approach to the problem. Any thoughts about it?

Edit: I was thinking: suppose $x,y \in \mathbb{Z}$ and $\gamma : [0,1] \to \mathbb{Z}$, where $\mathbb{Z}$ has co-finite topology. Further suppose $x \neq y$, then $f^{1}(\mathbb{Z}\setminus \{x\})=(0,1]$ which is not open in $[0,1]$, contradicting continuity. Hence $x=y$. Does it seem right?

Edit 2: Forget the (stupid) edit above!


To remove this question from the Unanswered list:

Suppose that $\gamma:[0,1]\to\Bbb Z$ is continuous but not constant. Then

$$\left\{\gamma^{-1}\big[\{n\}\big]:n\in\Bbb Z\right\}$$

is a non-trivial partition of $[0,1]$ into countably many closed sets. This MathOverflow question and its answers show that no such partition exists. For the sake of completeness I quote Tim Gowers’ very short answer:

I happen to have been thinking about this question recently. The proof I like uses the fact that a nested sequence of open intervals has non-empty intersection provided neither end point is eventually constant. Now one inductively constructs a sequence of such intervals as follows. Each interval is a component of the complement of the union of the first n closed sets, for some n. Then wait till the next closed set intersects that interval. (If it never does, then we're trivially done.) It cannot fill the whole interval, and indeed must miss out an interval at the left and an interval at the right. So pass to one of those subintervals in such a way that your left-right choices alternate. Done.