I am trying to read a file and reverse each line of it and display it to standard output in C.

my file is:

```
$ cat f1
this is line 1
this is line 2
this is line 3

```

My code is:

```
#include <stdio.h>
#include <string.h>

void reverse_string(char *s) {
    int l = strlen(s);
    int i;
    char sr[l];
    int j = 0;

    for (i = l - 1; i >= 0; i--) {
        sr[j] = s[i];
        j++;
    }
    printf("%s", sr);
}

int main(int argc, char *argv[]) {
    FILE *fp;
    int i;
    char filename[128];
    char line[100];

    for (i = 1; i < argc; i++) {
        strcpy(filename, argv[i]);
    }

    fp = fopen(filename, "r");

    while (fgets(line, 128, fp) != NULL) {
        if (strlen(line) != 0) {
            reverse_string(line);
        }
    }
    printf("\n");
}

```

Output is: 

```
$ ./mycode f1
(blank line here)
1 enil si siht
2 enil si siht
3 enil si siht

```

I am confused, why is there a extra blank line being output by my while loop even though there is no blank line in the file.