title: How to check if a line is blank, and if so, skip it, using scanner Java
body: <p>Lets say the lines in a file  are:</p>
  
  <p>Code:</p>
  
  <pre><code>String string = input.nextLine();
  int index=0;
  System.out.println(string);
  if(string.contains(" "))
  {
      while(string.contains(" "))
      {
         int random = string.indexOf(" ");
         String temp6 = string.substring(index,random);
         ps.print(pig(temp6)+" ");
         int temp8 = temp6.length();
         String temp7 = string.substring(temp8+1,string.length());
         string=temp7;
      }
      ps.print(pig(string));
  }
  else
  {
      ps.println(pig(string));
      //}
  }
  </code></pre>
  
  <p>For input:</p>
  
  <pre><code>Hello
  
  Bob
  </code></pre>
  
  <p>How would I get scanner to skip the line after Hello?
  Or how do I remove that blank line?</p>