Reading from a file will not always fill the buffer. Thats why n is returned. It will fail in a small number of cases. Thats basically just in the specification of the read interface. See io.