Move write_to_file() into util.py.
Use "\r\n" as newline character so file can display as expected on Windows.