move stream.on('close') code to index.js
grammar