diff options
-rw-r--r-- | FICS/utils.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/FICS/utils.c b/FICS/utils.c index d9fac79..992e410 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -789,11 +789,8 @@ truncate_file(char *file, int lines) if ((fp = fopen(file, "r")) == NULL) return 1; - while (!feof(fp)) { - if (fgets(tBuf[bptr], MAX_LINE_SIZE, fp) == NULL || feof(fp)) - break; - - if (tBuf[bptr][strlen(tBuf[bptr]) - 1] != '\n') { + while (fgets(tBuf[bptr], MAX_LINE_SIZE, fp) != NULL) { + if (strchr(tBuf[bptr], '\n') == NULL) { // Line too long fclose(fp); return -1; |