Getting null before each line while scanning txt file
<p>I'm having a problem reading a txt file and find a word/pattern using java's scanner.util. 
Currently testing out the reading and I'm getting null infront of each line. After that problem, I'm still not sure how to search for the pattern/word in the txt file. I also have to display the line which contains the pattern/word. </p>

<pre><code>public class SearchPattern {
   public static void main(String[] args) throws IOException{
      Scanner s = new Scanner(System.in);
      String pattern;
      String filename;
      String[] text = new String[10];
      System.out.println("Enter the filename");
      filename = s.nextLine();
      System.out.println("Enter the pattern you'd like to search");
      pattern = s.nextLine();
      // Print out each line that contains pattern
      // may need an array to store StringS of lines with word
      try{
         s = new Scanner(new BufferedReader(new FileReader(filename)));
         int x = 0;
         while (s.hasNext()) {
            text[x] += s.next();
            x++;
         }
      }
      finally {
         if (s != null) {
            s.close();
         }
      }
      text[0] = "test";
      System.out.println(text[0]);
      for(String txt : text){
         System.out.println(txt);
      }
   }
}
</code></pre>
