I think you're overcompensating with `linesep` here. `out` is `sys.stdout`, which is open in text mode, so `'\n'` will be translated to the line separator automatically.