You shouldn't use \r\n. Just use \n, but then open the stream in "text" mode, which than will do the conversion for you. You may not care about cross-platform, but this is the official way of doing it.
That way, the same code will spit-out \n on unix, \r\n on windows, and \r on mac.