So if you send EOF immediately after some data, it is likely that fread will return "a short object count" instead of zero like you expected, which ultimately determines gets return value. It is no different from what happens when reading a file. You may encounter EOF while you read the last line, but only the call after that fails for ...