The document.write function should allow a callback function to be passed through to fs.writeFile. Otherwise one doesn't know when the file has actually been written.. Nice library!