title: Java Buffered Reader, reading line by line
body: <p>Hey I have the following method that checks if a word is a legitimate word by looking through a large .txt file and checking if the word is there. Right now the method only works properly if the words in the .txt file are on the same line with only one space between one another. Is there any way I can make it so it reads through the list of words line by line; if there is one word per line. For example if the .txt file is oriented like this:</p>
  
  <p>word1</p>
  
  <p>word2</p>
  
  <p>Here is my method:</p>
  
  <pre><code>private boolean isWord(String word){
      try{
          //search .txt file of valid words. !!Will only read properly if there is a single space between each word.
          BufferedReader in = new BufferedReader(new FileReader("/Users/user/Documents/workspace/AnagramAlgorithm/src/words.txt"));
          String str;
          while ((str = in.readLine()) != null){
              if (str.indexOf(word) &gt; -1){
                  return true;
              }
              else{
                  return false;
              }
          }
          in.close();
      }
      catch (IOException e){
      }
      return false;
  }
  </code></pre>