int batch_mode = (argc == 2);
char input[INPUT_BUFFER_SIZE];
FILE *input_stream;

User *user_list = NULL;

if (batch_mode) {
    input_stream = fopen(argv[1], "r");
    if (input_stream == NULL) {
        perror("Error opening file");
        exit(1);
    }
} else {
    input_stream = stdin;
}

while (fgets(input, INPUT_BUFFER_SIZE, input_stream) != NULL) {
    if (batch_mode) {
        printf("%s", input);
    }

    char *cmd_argv[INPUT_ARG_MAX_NUM];
    int cmd_argc = tokenize(input, cmd_argv);

    if (cmd_argc > 0 && process_args(cmd_argc, cmd_argv, &user_list) == -1) {
        break;
    }

    printf("> ");
}

if (batch_mode) {
    fclose(input_stream);
}