write-stream.js 228 Bytes EditWeb IDE 1 2 3 4 5 6 const fs = require('fs') const stream = fs.createWriteStream('file.txt') stream.write('abc\n') // write the chunk of data 'abc\n' stream.write('def\n') // followed by the chunk 'def\n' stream.end() // close the stream