write with cached filehandles