In computing, newline is a special character or a sequence of characters indicating the end of a line.
Software applications and operating systems have various conventions for representing the end of a line of text, the so-called newline. This term, to be distinguished from "new line", is used for a code in a text to go to a line, as opposed to a new line that is the result of automatic wrapping by the program that displays the text.
Thus, for ordinary text, one or two newlines are used within a sequence of characters to separate paragraphs.
Newline is done with one or two control characters. Most systems use either LF (Line Feed) or CR (Carriage Return) individually, or CR followed by LF.
When a program stores text in a file using ASCII or an ASCII-compatible 8-bit encoding, as is typically the default, these characters are represented with their single ASCII bytes 0A, 0D, or 0D followed by 0A, respectively.
(ASCII was developed simultaneously by the ISO and the ASA, the predecessor organization to ANSI. During the period 1963-1968, the ISO draft standards supported the use of either CR+LF or LF alone as a newline, while the ASA drafts supported only CR+LF. The Multics operating system began development in 1964 and used LF alone as its newline. Unix followed the Multics practice, and later systems followed Unix.)
The sequence CR+LF was in common use on many early computer systems that had adapted teletype machines, typically a 33ASR, as a console device, because this sequence was required to position those printers at the start of a new line. On these systems text was often routinely composed to be compatible with these printers. The separation of the two functions concealed the fact that the print head could not return from the far right to the beginning of the next line in one character time. That is why the sequence was always sent with the CR first. In fact, it was often necessary to send CR, LF, NUL to be sure that the print head had stopped bouncing. Once these mechanical systems were replaced, the two character sequence had no functional significance, but it has persisted in some systems anyway.
Some mainframe operating systems still use EBCDIC, an IBM-proprietary 8-bit encoding that is completely incompatible with ASCII. In EBCDIC, the "Next Line" (NEL) code at X'15' is the typical end-of-line character.
On rare occasions, newlines are also called "line anchors" or "line breakers", reflecting the view of newlines. There are two views regarding newlines: a newline as a line separator and a newline as one that marks the end of the line. The problem is similar to a question whether to regard semicolons as a separator or as a terminator of statements in the syntax of programming languages. Although most of the time no complication arises due to the difference between the views, handing a newline at the end of the file could be troublesome. Most programs do not consider a newline at the end of the file introduces a new line after that character. This works because most of text files end with a newline after all.
The following table demonstrates the variations in the end-of-line conventions among OSes:
In the C standard I/O library, files can be accessed in either "text(t)" or "binary(b)" mode; when performing input or output in text mode, on a system where lines are not terminated by the C newline character '\n', the native line termination is automatically translated into a C newline. (This is a legacy of C's historic grounding in Unix, where there is no need for such a distinction.)