allow writing attributes with write-only perms

* replace "r+" with "w" in fopen() flags to avoid EACCES when
opening attribute files with no read permission.