It stops when either (n-1) characters are read, the newline character is read, or the end-of-file is reached, whichever comes first. Same from man fgets : fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline.