We recently had to remind ourselves how different operating-systems terminate the end of a line of text.
All operating-systems use a special character (or combination of characters) to indicate the end of one line and the start of another. Unfortunately different operating-systems use different conventions and interpret these characters differently, which can cause problems when transferring text documents from one system to another (using SSH, SFTP, SCP or FTP [in binary mode]).
In particular the three most common operating-systems (Windows, Linux/Unix and Mac OS) all treat line-endings differently. All of these operating-systems started life supporting the ASCII character set, which standardises 128 different 'characters' as decimal values, including 'special' characters, such as those used to indicate the end of a line.
Without going into specifics:
ASCII Value of 65 = Letter 'A'
ASCII Value of 66 = Letter 'B'
...
ASCII Value of 90 = Letter 'Z'
etc
Most operating-systems have now moved to natively support Unicode characters sets (most noticeably UTF-8). However, Unicode is backwards-compatible with ASCII, so the traditional line-ending problem still exists!
Briefly then, there are two 'special' characters in the ASCII (and hence Unicode) character-sets that are typically used to denote the end of a line:
ASCII Value of 10 = CR -> Carriage Return
ASCII Value of 13 = LF -> Line Feed
Why two values?
The reason originates from the days of type-writers, which classically had two separate keys to start a new line; the carriage-return key (which returned the 'carriage' [containing the inking ribbon] back to the left of the type-writer) and the line-feed key (which shunted the paper up by one line). These were two separate actions, done by two separate keys on the typewriter.
Consider the following - a typist might need to correct a spelling mistake on a line they have just typed; in this case they would only press the carriage-return key in order to release the carriage and send it back to the left of the type-writer. They would then use correctional fluid (or some other technique) to erase the incorrect character(s), before manually moving the 'carriage' forwards to the relevant position on the line and typing over the mistake.
Once the mistake has been corrected the typist would press both the carriage-return and the line-feed keys to return the carriage back to the left and shunt the paper up, so they can start typing a new line.
When the ASCII standard was defined (1963) it was largely based on existing typewriter keyboards - consequently both the CR and LF keys were included as ASCII values.
However, computers only require a single value to denote the end of a line. This meant that operating-system programmers had two ASCII codes to choose between - sure enough, different authors chose different characters!
These are the current conventions:
Windows : CRLF
Linux : LF
Mac : CR
In other words, Linux (and Unix) systems do not use the carriage-return (CR) ASCII representation to denote the end of a line; these operating-systems use just the LF character. True to form the Mac OS operating-system uses exactly the opposite - a CR character represents the end of a line, with the LF character not being used.
Finally, the Microsoft operating-systems (starting from MS-DOS) use both ASCII characters to represent a new line - a CR followed by a LF.
None of these is wrong - at the end of the day it shouldn't really matter what character is used, as long as the convention is well-know and followed.
However, from a historical perspective we can see that the Microsoft approach follows the original typewriter most accurately - the disadvantage of this approach is that each line of text contains an extra character that is arguably redundant. This in turn can result in larger file-sizes.