title: Searching through data - not reading last line
body: <p>I have a program which searches through a mini-database I have created in a text file, everything works fine, except the fact that whatever is the very last line in the last line of the data is not recognized and whenever I attempt to search for it, it will fail and I am informed that the data does not exist in the database, although it very clearly does when I look at the txt file. </p>
  
  <p>I managed to get a work-around for this, but adding a fake line at the very end that didn't have data, and something I would use such as "xxxxxxxxxx", and then it was able to read the data on top, which originally was the last line before. The problem with this is, I also have to be able to add data to the function straight from my java program, and it would be extremely tedious to have to first remove that fake line, add my information, then put the fake line in again, so I am trying to figure out why it is not searching the last line of my data.</p>
  
  <p>Here is the code for one of my searches:</p>
  
  <pre><code>BufferedReader i = new BufferedReader (new FileReader ("Elements.txt"));
  String data=i.readLine();
  while (data!=null)
      {
          String database[]=data.split(",");
          data=i.readLine();
          if (data!=null)
          {
              for (int x=0;x&lt;data.length(); ++x)
              {
                  if (database[0].equalsIgnoreCase(elementName))                                                                                  
                  {
                      element=database[0];                                                                                                        
                      symbol=database[1];
                      atomicNumber=database[2];
                      atomicMass=database[3];
                      valence=database[4];
  
                      found=true;                                                                                                                        
                      break;
                  }
              }
          }
      } 
  </code></pre>
  
  <p>Here is the data that it is searching through:
  <a href="http://i.imgur.com/GeXQhTh.png" rel="nofollow">http://i.imgur.com/GeXQhTh.png</a></p>
  
  <p>Any idea on how to fix this?</p>