This function is supposed to search through a text file for the new line character. When it finds the newline character, it increments the newLine counter, and when
newLine
[EDITED] The minimal change is:
if ( newLine <= 2)
forgive me and forget the previous code.
a slightly simpler alternative:
int c; int duplicates=0; while ((c = fgetc(fileContents)) != EOF) { if (c == '\n') { if (duplicates > 1) continue; duplicates++; } else { duplicates=0; } putchar(c); }