java scanner nullpointer exception when end of file is reached
Okay I may be doing something stupid or this should be a simple fix but basically I have a text file I am reading from with a scanner object and I am getting a nullpointer exception when I reach the end of the file I was wondering how to get fix this

    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.util.Scanner;
    
    public class FileAccess {
      public static void main (String[] args) throws IOException {
        Scanner s = null;
    
        try {
          s = new Scanner(new BufferedReader(new FileReader("move_list.txt")));
          while (s.hasNext()) {
              System.out.println(s.next());
          }
        }
        finally {
          if (s != null) {
            s.close();
          }
        }
      }
    }

Once it reaches the end I get:
Exception in thread "main" java.lang.NullPointerException
   at java.util.regex.Matcher.toMatchResult(libgcj.so.10)
   at java.util.Scanner.myCoreNext(libgcj.so.10)
   at java.util.Scanner.hasNext(libgcj.so.10)
   at FileAccess.main(FileAccess.java:13)

    `
java scanner nullpointer exception when end of file is reached
===

Okay I may be doing something stupid or this should be a simple fix but basically I have a text file I am reading from with a scanner object and I am getting a nullpointer exception when I reach the end of the file I was wondering how to get fix this

    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.util.Scanner;
    
    public class FileAccess {
      public static void main (String[] args) throws IOException {
        Scanner s = null;
    
        try {
          s = new Scanner(new BufferedReader(new FileReader("move_list.txt")));
          while (s.hasNext()) {
              System.out.println(s.next());
          }
        }
        finally {
          if (s != null) {
            s.close();
          }
        }
      }
    }

Once it reaches the end I get:
Exception in thread "main" java.lang.NullPointerException
   at java.util.regex.Matcher.toMatchResult(libgcj.so.10)
   at java.util.Scanner.myCoreNext(libgcj.so.10)
   at java.util.Scanner.hasNext(libgcj.so.10)
   at FileAccess.main(FileAccess.java:13)

    `