<p dir="ltr">On 17 May 2013 19:38, "Carlos Nepomuceno" <<a href="mailto:carlosnepomuceno@outlook.com">carlosnepomuceno@outlook.com</a>> wrote:<br>
><br>
> Think the following update will make the code more portable:<br>
><br>
> x += len(line)+len(os.linesep)-1<br>
><br>
> Not sure if it's the fastest way to achieve that. :/<br>
></p>
<p dir="ltr">Putting len(os.linesep)'s value into a local variable will make accessing it quite a bit faster. But why would you want to do that?</p>
<p dir="ltr">You mentioned "\n" translating to two lines, but this won't happen. Windows will not mess with what you write to your file. It's just that traditionally windows and windows programs use \r\n instead of just \n. I think it was for compatibility with os/2 or macintosh (I don't remember which), which used \r for newlines.</p>

<p dir="ltr">You don't have to follow this convention. If you open a \n-separated file with *any* text editor other than notepad, your newlines will be okay.<br>
</p>