I\'m trying to make a simple script which takes a list of names off the clipboard formatted as \"Last, First\", then pastes them back as \"First Last\". I\'m using Python 3 and
Apparently I need to use '\r\n' instead of just '\n'. I don't know exactly why this is but I found that answer on the internet and it worked.
To include newlines in your file, you need to explicitly pass them to the file methods. On Unix platforms, strings passed into .write should end with \n. Likewise, each of the strings in the sequence that is passed into to .writelines should end in \n. On Windows, the newline string is \r\n. To program in a cross platform manner, the linesep string found in the os module defines the correct newline string for the platform:
>>> import os
>>> os.linesep # Unix platform
'\n'
Souce: Illustrated Guide to Python 3