Take a look at this: https://stackoverflow.com/questions/60026137/why-is-scanner-reading-first-before-the-output