They both mean "new line" but when is one used over the other?
\r\n
is a Windows Style
\n
is a POSIX Style
\r
is a old pre-OS X Macs Style, Modern Mac's using POSIX Style.
\r
is a carrige return and \n
is a line feed, in old computers where it not have monitor, have only printer to get out programs result to user, if you want get printing from staring of new line from left, you must get \n
for Line Feed, and \r
for get Carriage return to the most left position, this is from old computers syntax saved to this time on Windows platform.