fixed the file open issues with pathToFile