title: NodeJS, fs.readFileSync string-by-string reading, and operating. How?
body: <p>Sorry for so dumb question, </p>
  
  <p>How i can in NodeJS read from file string by string some value, for example - url, and do operation with each string eventually?</p>
  
  <pre><code>var contents = fs.readFileSync('test.txt', 'utf8');
  </code></pre>
  
  <p>and what then? </p>
  
  <p>It's need for browserstack+selenium testing. 
  I want run some links one-by-one, from file and do something with them. </p>
  
  <p>Changed code below: 
  from </p>
  
  <pre><code>console.log(lines[i++])
  </code></pre>
  
  <p>to</p>
  
  <pre><code>line = (lines[i++])
  driver.get(line);
  driver.getCurrentUrl()
                  .then(function(currentUrl) {
                     console.log(currentUrl);
  </code></pre>
  
  <p>But it works once.</p>
  
  <p>And </p>
  
  <pre><code>var str=fs.readFileSync('test.txt');
  str.split(/\n/).forEach(function(line){})
  
  
  C:\nodejstest&gt;node test1.js
  C:\nodejstest\test1.js:57
  str.split(/\n/).forEach(function(line){
      ^
  
  TypeError: str.split is not a function
      at Object.&lt;anonymous&gt; (C:\nodejstest\test1.js:57:5)
      at Module._compile (module.js:413:34)
      at Object.Module._extensions..js (module.js:422:10)
      at Module.load (module.js:357:32)
      at Function.Module._load (module.js:314:12)
      at Function.Module.runMain (module.js:447:10)
      at startup (node.js:142:18)
      at node.js:939:3
  </code></pre>
  
  <p>Works!
  Much thanx!</p>