title: Search a file for a String and return that String if found
body: <p>How can you search through a txt file for a String that the user inputs and then return that String to the console. I've written some code that doesn't work below, but I hope it can illustrate my point...</p>
  
  <pre><code>public static void main(String[] args) {
    searchforName();
  }
  
     private static void searchForName() throws FileNotFoundException {
      File file = new File("leaders.txt");
      Scanner kb = new Scanner(System.in);
      Scanner input = new Scanner(file);
  
      System.out.println("Please enter the name you would like to search for: ");
      String name = kb.nextLine();
  
  
      while(input.hasNextLine()) {
          System.out.println(input.next(name));
      }
  }
  </code></pre>
  
  <p>The "leaders.txt" file contains a list of names.</p>