Python script to extract unique lines from a file, and write it to a new file