Use Writable Streams instead of fs.write

Much safer when performing multiple writes.