reads a line of text from a file and returns it as a string.
reads a line of text from a stream and returns it as a string.
reads a line of text generated by an external process and returns it as a string.
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 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"].
Examplesopen allclose all
Basic Examples (3)
Read the first line of a File object:
Wolfram Research (2014), ReadLine, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadLine.html (updated 2016).
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. Retrieved from https://reference.wolfram.com/language/ref/ReadLine.html