Fixed issue with wring permission check for file openings