Fixed "access denied" bug with opening files