ReadLine
✖
ReadLine
Details and Options

- ReadLine reads until it encounters a newline, either "\n" or "\r\n".
- ReadLine[File["file"],…] is also supported.
- ReadLine["file",…] and ReadLine[File["file"],…] will first open "file" for reading if it is not already open. The file will be left open until it is closed by a call to Close.
- ReadLine["file",…] and ReadLine[File["file"],…] open "file" using OpenRead with BinaryFormatTrue.
- ReadLine is a blocking function that by default will not return until it has read a complete line of text.
- With the option setting TimeConstraint->t, ReadLine waits at most t seconds, then returns whatever it has read by that time.
- If ReadLine is called on a source of content that has already been exhausted, it returns EndOfFile.
- ReadLine[src] is equivalent to ReadString[src,"\n" "\r\n"].
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Read the first line of the file "ExampleData/strings":

https://wolfram.com/xid/0cqz06zo-s9j1dz


https://wolfram.com/xid/0cqz06zo-4f6iso


https://wolfram.com/xid/0cqz06zo-q29fuh


https://wolfram.com/xid/0cqz06zo-l8o8tt

Start the system shell process:

https://wolfram.com/xid/0cqz06zo-hp8oi3

Read all initial output; depending on the operating system and shell, this can result in an empty string:

https://wolfram.com/xid/0cqz06zo-f7be3i
Write a command into the shell:

https://wolfram.com/xid/0cqz06zo-6j3c93

https://wolfram.com/xid/0cqz06zo-32mxq4

Start the system shell process:

https://wolfram.com/xid/0cqz06zo-1voo50

Read all initial output; depending on the operating system and shell, this can result in an empty string:

https://wolfram.com/xid/0cqz06zo-dtvr3g
Write two "echo" commands in the shell, then close it with "exit":

https://wolfram.com/xid/0cqz06zo-thxrfy
Read the shell process output:

https://wolfram.com/xid/0cqz06zo-8r362x


https://wolfram.com/xid/0cqz06zo-g50v84


https://wolfram.com/xid/0cqz06zo-efcdg0

Scope (1)Survey of the scope of standard use cases
Read the first line of a File object:

https://wolfram.com/xid/0cqz06zo-0gw01t


https://wolfram.com/xid/0cqz06zo-cg7rsr

Wolfram Research (2014), ReadLine, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadLine.html (updated 2016).
Text
Wolfram Research (2014), ReadLine, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadLine.html (updated 2016).
Wolfram Research (2014), ReadLine, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadLine.html (updated 2016).
CMS
Wolfram Language. 2014. "ReadLine." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/ReadLine.html.
Wolfram Language. 2014. "ReadLine." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/ReadLine.html.
APA
Wolfram Language. (2014). ReadLine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReadLine.html
Wolfram Language. (2014). ReadLine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReadLine.html
BibTeX
@misc{reference.wolfram_2025_readline, author="Wolfram Research", title="{ReadLine}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/ReadLine.html}", note=[Accessed: 06-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_readline, organization={Wolfram Research}, title={ReadLine}, year={2016}, url={https://reference.wolfram.com/language/ref/ReadLine.html}, note=[Accessed: 06-April-2025
]}