why is this giving me infinite while loop?
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, " ");

        Rule *r2 = NULL;
        Rule *curr2 = head;

        while (token != NULL) {
            while (curr2 != NULL) {
                if (strcmp(curr2->target, token) == 0) {
                    r2 = curr2;
                }
                curr2 = curr2->next_rule;
            }

            if (r2 == 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, " ");
        }
    }
}
