You have included cmath twice, but that's not likely to cause the problem you describe. When programs compile, but then don't run appropriately, it is harder to debug them. In this case the syntax of obtaining file names and associating them with files, etc. seem appropriate. Therefore, I would try printing the file names to the screen using cout statements to be sure they have been input appropriately. IF that doesn't work, then posting the exact output that is unexpected and/or error statements you encounter would be helpful. If that still doesn't work I'd start commenting out stuff until I got back to a bare bones program without all the fluff of try/catch etc. to confound the issue and proceed until I got the program running. Then I'd add back sections, one at time and testing each one as they are reintroduced until I tracked the problem down to a (given set of) line(s).