Improved file permissions check.