title: How to write a recursive method for returning all lines in a file containing a token String
body: <p>My professor gave us an assignment to write a program that does a lot of things. One thing in specific this program does is go through a <code>.txt</code> file, and return all the instances of a word you specify and the line where they are located. For example, if this is the text file:</p>
  
  <blockquote>
    <p>This is a test.<br>
    Testing the word file.<br>
    This will be considered a test.</p>
  </blockquote>
  
  <p>After running the method and searching for the word "test" you should receive back something like:</p>
  
  <pre><code>1: This is a test.       
  3: This will be considered a test.
  </code></pre>
  
  <p>Now this is my problem. He wants us to do it in a recursive method, and I am not sure how to start up the method. I know for a recursive method you must call itself and reduce every time you call it, but, the parameter for this method is a word. Say I have:</p>
  
  <pre><code>String getTheWord (String word) {     
      if (word == 0){    //which still wouldn't compile, so I think I should use word == null     
          // something    
      }
  
      //something smart here      
  
      return getTheWord(word - 1); // which wouldn't compile
  }
  </code></pre>
  
  <p>So how should I go about writing this? I think I must use a string for the parameter because how else will I know what the word I am looking for is? Or maybe I'm wrong, anything helps!</p>