title: Scanner Class hasNextLine infinite loop
body: <p>why does this piece of code go into an infinite loop when I try to give it a basic text file?</p>
  
  <pre><code>import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.*;
  public class TestFile
  {
  
      public static void main(String args[]) throws IOException
      {
              // Read in input file                                                                                                                                            
              File input = new File(args[0]);
              Scanner freader = new Scanner(input);
              while (freader.hasNextLine()) {
                  System.out.println("hi");
              }
  
              freader.close();
  
      }
  
  }
  </code></pre>
  
  <p>The print line just keeps going.</p>