Here is the problem:
char *infilename = argv[1];
char *outfilename = strcat(infilename, MORD);
strcat()
will change infilename
, and append that MORD
to the end of it, therefore you are using argv[1].mord
as your input file name. I bet it is a empty file.
Solution:
Change
char *outfilename = strcat(infilename, MORD);
to
char *outfilename = malloc(strlen(infilename) + strlen(MORD) + 1);
if (outfilename == NULL) { /* malloc failed */ }
strcpy(outfilename, infilename);
strcat(outfilename, MORD);