Commit Diff


commit - b57978b307b88821ea1d7d7972e01537805f7d0c
commit + a0eeb184e4277b15e4408c2b29db150dcf42f6bb
blob - d9fac79192fc15565bf98e32d8ea2205c4dbd662
blob + 992e410e36bba95bc52408570fab22b85fb6c1de
--- FICS/utils.c
+++ 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;