title: How to force close a readable stream?
body: <p>I need force close a readline file... IN LINE 11! I need optimization!! But not workd the call <code>this.emit("close");</code><a href="https://i.stack.imgur.com/G67Gv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G67Gv.png" alt="enter image description here"></a></p>
  
  <pre><code>var readline = require('readline');
      var stream = require('stream');
      function get_line3(filename, number, callback) {
          var instream = fs.createReadStream(filename);
          var outstream = new stream;
          var rl = readline.createInterface(instream, outstream);
          var contp = 0;
          var data = "";
  
          rl.on("line", function(line) {
              console.log(contp);
              if (contp==number) this.emit("pause", line);
              contp++;        
          });
  
          rl.on("pause", function(line) {
              // do some work here
              console.log("doing some work");
              console.log(line);
              data = line;
              this.emit("resume");
          }); 
  
          rl.on("resume", function(line) { 
              this.emit("close"); // NOT WORK !!!
          });
  
          rl.on("close", function() {
              // do something on finish here
              callback(null, data);   
          });
      }
  </code></pre>