Rule *parse_file(FILE *fp) {
    char line[MAXLINE];
    char buffer[MAXLINE];
    Rule *first_rule;
    Rule *curr;

    while (fgets(line, MAXLINE, fp)) {
        if (is_comment_or_empty(line)) {
            continue;
        }
        if (line[0] == '\t' || line[0] == '\r' || line[0] == '\n') {
            continue;
        } else {
            strncpy(buffer, strtok(line, ":"), MAXLINE);
            buffer[MAXLINE - 1] = '\0';
            char *target = malloc(sizeof(char) * (strlen(buffer) + 1));
            target[strlen(buffer)] = '\0';
            strncpy(target, buffer, strlen(buffer) + 1);

            if (first_rule == NULL) {
                first_rule = make_new_rule(target);
                curr = first_rule;
            } else {
                curr = get_rule(target, first_rule);
                if (curr == NULL) {
                    get_tail(first_rule)->next_rule = make_new_rule(target);
                    curr = get_tail(first_rule);
                }
            }
            free(target);

            char *dependency = strtok(strtok(NULL, ":"), " ");
            while (dependency != NULL) {
                make_dependency(curr, dependency, first_rule);
                strncpy(dependency, strtok(NULL, " "), MAXLINE);
            }
        }
    }

    return first_rule;
}