I think the issue here is with the -
fin.open(donefile.c_str(), ifstream::in);
line.
According to your code, you have assigned the first argument as -
tfile.assign(argv[1]);
So, tfile contains the File Name: test.txt

Hence the line would be -
fin.open(tfile.c_str(), ifstream::in);

Hope I am not missing anything here.