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.