Use writeln() instead of write()