Added file permission check