use a buffer to cache bytes to be written to disk, but currently still
does not work.