corrected write permissions error handling