Don't open files in binary mode. Use os.linesep instead of \n