why is this code giving finite while loop?

Rule *parse_file(FILE *fp) {
    char line[MAXLINE];
    Rule *head = NULL;
    Rule *r;

    while (fgets(line, MAXLINE, fp) != NULL) {
        line[MAXLINE - 1] = '\0';

        int i = MAXLINE - 1;
        while (isspace(line[i]) != 0) {
            line[i] = '\0';
            i--;
        }

        if (is_comment_or_empty(line) != 1) {
            char *token;
            token = strtok(line, " ");

            while (token != NULL) {
                if ((isspace(token[0]) == 0) && (strcmp(token, ":") != 0) && (token[0] != '\t')) {
                    Rule *r = NULL;
                    Rule *curr2 = head;
                    while (curr2 != NULL) {
                        printf("%s\n", curr2->target);
                        if (strcmp(curr2->target, token) == 0) {
                            r = curr2;
                            break;
                        }
                        curr2 = curr2->next_rule;
                    }

                    if (r == NULL) {
                        r = malloc(sizeof(Rule));
                        r->target = strdup(token);
                        r->actions = NULL;
                        r->dependencies = NULL;
                        r->next_rule = NULL;
                    }

                    if (head == NULL) {
                        head = r;
                    } else {
                        Rule *curr = head;
                        while (curr->next_rule != NULL) {
                            curr = curr->next_rule;
                        }
                        curr->next_rule = r;
                    }
                }
                token = strtok(NULL, " ");
            }
        }
    }
    return head;
}