This sort of thing is why it'd be *Really Good* to factor
out the common code used here and in tail.c.
goto free_lbuffers;
}
- /* Count the incomplete line on files that don't end with a newline. */
- if (last->buffer[last->nbytes - 1] != '\n')
+ /* If we read any bytes at all, count the incomplete line
+ on files that don't end with a newline. */
+ if (last->nbytes && last->buffer[last->nbytes - 1] != '\n')
{
++last->nlines;
++total_lines;