counting digits while reading from a file
===

let's say I have a file of mostly numbers, and some letter

    1
    4
    5
    d o
    2
    8 22
    6
    f
so I want to count the how many numbers and letters, and I can only use nextInt() method. Here's the code I'm using, but for some reason I get an endless loop, after doing some debugging (printing input) it will stop at number 5. why am I doing wrong here?

    public static void mixedF() {
            int numbers = 0; 
            int words = 0;
            int num;      
            try {
                Scanner in = new Scanner(new File("myFile.txt"));
                while(in.hasNext()) {
                    try {
                        num = in.nextInt();
                        System.out.println(num);
                        numbers++; 
                    }
                    catch (InputMismatchException e) { words++; }              
                    
                    }            
                
                System.out.println("numbrers: "+numbers);
                System.out.println("words: "+words);
            }
            catch (FileNotFoundException ex) { ex.getMessage(); }        
        }