As you know arrays start with index `0`.
it means name of `outfile` should be `char *outfile = argv[3];` , not `argv[4]`.