Connectedness and continuity

The following is a theorem from my book, but i don't think that i follow the proof given:

Theorem:

Every continuous image of a connected metric space is connected.

Proof:

Suppose X and Y are metric spaces and g : X -> Y is continuous.

Suppose g(X) is not a connected space.

Then there exists a continuous function f from g(X) onto {0,1}. (i don't think i follow this)

This yields (fog)(X) = f(g(X)) = {0,1}, and since fog is continuous,

X does not satisfy the continuity criterion for connectedness and therefore is not connected. (I don't understand how this happens ? why is it not satisfying the continuity criterion ?)

Any help will be appreciated.

Re: Connectedness and continuity

Suppose is not connected. Then, where , and both and are open and nonempty. Define by . Now, is continuous if the preimage of open sets are open. So, let's look at the open sets of . They are . The preimage of the empty set is the empty set, which is open in . The preimage of is , which is open in . The preimage of is , which is open in , and the preimage of is , which is obviously open in . So, is continuous. You have already seen the proof that the composition of continuous functions is continuous. So, must be a continuous function. Hence, must be disjoint, nonempty, open subsets of whose union is . This implies is not connected.

Edit: Disjoint comes from the definition of a function. If they were not disjoint, then let . Then and implying is not even a function.

Nonempty comes from the fact that are nonempty subsets of , so and must be nonempty subsets of .

Open comes from continuity of .

The union because the preimage of the entire image of a function is the entire domain.