line count returns 2 less than expected
16:47 18 Apr 2026
        // Last task removal
        if(!strcmp(argv[2], "last")) {
            int line = 0; // Which line is last in the file
            
            FILE *fileptr = fopen(FileAddress, "r"); // Create file pointer and open it in read and write
            
            char* filebuffer = calloc(10000, sizeof(uint8_t)); // Create memory on the heap

            while(fgetc(fileptr) != EOF) { // Loop through the file until end of file
                if (fgetc(fileptr) == 10) { // Check if its a new line
                    line++; // Increment line count
                }

            }

            printf("%d", line);
        
        
        }

This code is supposed to return how many lines are in a simple txt file but for some reason it returns 2 less than expected every single time. I have tried to fix this myself but for the life of me can't figure it out

Also, yes I know the code is probably bad but this is my second ever C project after a number guessing game. There is definitely a better way to do this but I'm trying my best so just be nice :(

c