I have a problem, in my program I want to read a .txt file with Scanner the txt file looks like:

```
10  2
20  3
30  5
40  6
750

```

I want to store each column in a `List` but the last row which is `750` to store separately in a `int` variable. I tried something like:

```
public class Testing {

    final static Charset ENCODING = StandardCharsets.UTF_8;

    public static LinkedHashMap<Integer, Integer> readTextFile() throws IOException {

LinkedHashMap<Integer, Integer> finalT = new LinkedHashMap<Integer, Integer>();
        int suma;
        List<Bancnota> bancnote = new ArrayList<Bancnota>();
        String userHomeFolder = System.getProperty("user.dir");
        String finalPath = userHomeFolder + "/src/atm/TEST.txt";
        Path path = Paths.get(finalPath);

        try (Scanner scanner = new Scanner(path, ENCODING.name())) {

            while (scanner.hasNext()) {
                String line = scanner.nextLine();
                String arr[] = line.split(" ");
             if (arr.length == 2){

                finalT.put(scanner.nextInt(), scanner.nextInt());
                System.out.println(finalT);
         } else {

          suma = scanner.nextInt();      
               }  
             }
            scanner.close();
          }  
        return finalT;
    }

```

But something is not working, when I delete `750` from text file and delete this part 

```
String line = scanner.nextLine();
String arr[] = line.split(" ");

          if (arr.length == 2){

```

everything is working. Is there any way to make the scanner to stop at last row? Thank you