why are we flushing on each line ? we can flush at the end