title: Looping through the text file in typescript
body: <p>I have read a local file <code>flight.txt</code></p>
  
  <pre><code>1 DFW BOM 2016-05-20 12:20 2016-05-21 02:40 1084.00 JetAirways 100
  2 DFW DEL 2016-04-24 17:15 2016-04-25 07:20 1234.00 Lufthansa 100
  3 DFW FRA 2016-06-05 13:30 2016-06-05 03:32 674.00 AmericanAirlines 100
  </code></pre>
  
  <p>Code used to read a file in typescript.</p>
  
  <pre><code> populateFlightList() {
     let data = fs.readFileSync('flight.txt').toString('utf-8'); {
          let textByLine = data.split("\n")
          console.log(textByLine);
  
      };
  </code></pre>
  
  <p>now i want to loop and read from the file and parse data into flight objects
  by creating a new object in each iteration and adding it to an arraylist.</p>
  
  <pre><code>   try {
          Scanner fin = new Scanner(file);                
          while(fin.hasNext()) {
            int number = fin.nextInt();                 //flight numer
            String from = fin.next();                   //Departure airport
            String to = fin.next(); //Arrival airport
      }**Code in Java**
  </code></pre>
  
  <p>how do i do this in typescript?</p>