Good question.
What does a function like readLines()
do?
In OS terms it reads from stdin and writes to stdout, a line at a time. So, it eats a line and then looks for the next line. But what if there is no next line? It could either say, "fine, I'll go with what I got," or "guess I'll have to wait until I'm fed," or "better tell the user I need to know when I'm done."
This isn't a problem on the OS terminal because the operating system has the go-with-that choice baked in. But in character devices, like a file, the C/C++
program needs to be told.
man getc
from the terminal will give you the gory details.