Write buffer to disk on flush