print error if write/close file return error