Make the bufferToFile more non-UNIX friendly