title: While loop not running?
body: <p>I am working on a java problem at the moment where I am creating a program that simulates the old TV quiz show, You Bet Your Life. The game show host, Groucho Marx, chooses a secret word, then chats with the contestants for a while. If either contestant uses the secret word in a sentence, he or she wins $100.00.</p>
  
  <p>My program is meant to check for this secret word.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import java.util.Scanner; 
  
      public class Groucho{
        String secret; 
  
          Groucho(String secret){
          this.secret = secret; 
        }
  
        public String saysSecret(String line){
          if(secret.equals(line)){
           return("You have won $100! The secret word is: " + secret);
          }
          else{
            return("false");
          }
        }
  
        public void main(String[] args){
          Scanner in = new Scanner(System.in); 
          String line = in.nextLine();
          Groucho g = new Groucho(line);
  
        while (in.hasNextLine()) {
            Scanner input = new Scanner(System.in);
            String guess = input.nextLine();
            saysSecret(guess);
  
          }
        }  
      }
  </code></pre>
  
  <p>I thought his should work but when I run it I get: </p>
  
  <pre><code>java.lang.NullPointerException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)
  </code></pre>
  
  <p>Could someone explain what I am doing wrong? 
  Many thanks!
  Miles</p>