title: Displaying specific words in a .txt file using a scanner
body: <p>I'm stuck and need your help (yes, it's homework), what I'm trying to do is get my code to read the contents in the text file and output the words by specific words. For example I want it to output all words that start with letter "g". </p>
  
  <p>Here's a pseudocode code if I didn't explain that well:</p>
  
  <pre><code>BEGIN
  
  Get the initial letter from the user
  
  While there are more entries in the file
  
  Get the next personal name
  
  Get the next surname
  
  Get the next year info
  
  If the surname starts with the initial letter
  
  Output the person name, surname and year info
  
  End while
  
  END
  </code></pre>
  
  <p>So far I've managed to get this done, and now I'm stuck where you output the names correctly. Any help or tutorials will be appreciated.</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.File;
  import java.io.FileNotFoundException;
  
  public class PrimeMinisters
  {
      public static void main(String[] args) throws FileNotFoundException
      {
          // ask the user for the first letter
          Scanner keyboard = new Scanner(System.in);
          System.out.print("What is the first letter? ");
          String input = keyboard.next().toLowerCase();
          char firstLetter = input.charAt(0);
  
          // open the data file
          File pmFile = new File ("OZPMS.txt");
          // create a scanner from the file
          Scanner pmInput = new Scanner (pmFile);
  
          // read one line of data at a time, processing each line
          while(pmInput.hasNext())
          {
              String names = pmInput.next();
              System.out.println(names);
          }
  
          // be polite and close the file
          pmInput.close();
      }
  }
  </code></pre>