var fs = require('fs') var myReadStream = fs.createReadStream(__dirname + '/book.txt') var myWriteStream = fs.createWriteStream(__dirname + '/copy.txt') myReadStream.setEncoding('utf8') var data = '' myReadStream.on('data', function(chunk){ data += chunk }) myReadStream.on('end', function(){ console.log(data) myWriteStream.write(data) })