title: Java doesnt locate text file
body: <p>So my code is really simple. I want to locate a txt file and if it doesnt exists the program should ask for the file name again</p>
  <pre><code>public static void main(String[] args) {
      System.out.println(&quot;Enter the file you want to check &quot;);
      Scanner scanner = new Scanner(System.in);
      String input = scanner.nextLine();
      
      File file = new File(input);
  
      while(!file.exists()){
  
          System.out.println(input + &quot; doesn't exist! Try again.&quot;);
          input = scanner.nextLine();
         
          file = new File(input);
  
      }
      System.out.println(&quot;Exists&quot;);
      scanner.close();
  }
  </code></pre>
  <p>The problem is that even though I input a file that exists in my computer (ex: test.txt) I enter the while loop. Is this some kind of glitch or is it something wrong with my code ?</p>