Obviously, my real code is more complex, but here's an example:
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in).useDelimiter("\n");
        String[] cmdSplit = null; 
        while (true) {
            while (input.hasNext()) {
                cmdSplit = input.next().split("\\s+");
                System.out.println("stuff");
            }
            for (int i = 0; i < cmdSplit.length; i++) System.out.println(cmdSplit[i]);
        }
    }
}
In the above example, the code takes input from System.in, splits it, and should output each piece. However, for some reason, the code after the inner while loop never executes. If I replace while with if, it works. If you test it, you can see it doesn't run infinitely, because it only prints "stuff" once, showing the loop runs once. What is the issue with the while loop?