Complex Analysis Question

Homework Statement

Show that if the analytic function w= f(z) maps a domain D onto a portion of a line, then f must be constant throughout D.

The Attempt at a Solution

I just have one question, can I write w = u(x,y) (a+bi) since it maps to a portion of a line? Where a,b, and u(x,y) are reals. From there I have shown that the derivatives are 0.