I would like to make sure only child calls fork() but now it only calls it once and terminates when i = 2. So I only get one process from the child instead of 2.
int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr, "Usage: forkloop <iterations>\n");
        exit(1);
    }

    int iterations = strtol(argv[1], NULL, 10);
    int n;
    fork();

    for (int i = 0; i < iterations; i++) {
        if (n == 0) {
            n = fork();
        }
        if (n < 0) {
            perror("fork");
            exit(1);
        }
        printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i);
    }

    return 0;
}