The reason I used the Cwd module is because I needed to change the current directory in order for the program to function. Hence, when I use your program, I have the same issue: it will be unable to open the files until the working directory is changed within the program.
Bioinformatics