Line following with magnetic sensor

Well, its not wrong.

You may also be helped by: State Machine