Fix ansi color handling for line overwriting case.