tested do while loop and buffer.
cleaned up read_lines function