title: Java: RuntimeException when run on spoj.com
body: <p>Following is the question for prime number generator problem (from spoj.com):</p>
  
  <p>Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers!</p>
  
  <p><strong>Input :</strong></p>
  
  <p>The input begins with the number t of test cases in a single line (t&lt;=10). In each of the next t lines there are two numbers m and n (1 &lt;= m &lt;= n &lt;= 1000000000, n-m&lt;=100000) separated by a space.</p>
  
  <p><strong>Output :</strong></p>
  
  <p>For every test case print all prime numbers p such that m &lt;= p &lt;= n, one number per line, test cases separated by an empty line.</p>
  
  <p><strong>Example :</strong></p>
  
  <p>Input:</p>
  
  <pre><code>2
  
  1 10
  
  3 5
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>2
  
  3
  
  5
  
  7
  
  
  3
  
  5 
  </code></pre>
  
  <p>Following is my code for the same:</p>
  
  <pre><code>package competitivecoding;
  
  import java.util.Scanner;
  
  class problem2{
  public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      Scanner st = new Scanner(System.in);        
      int t = sc.nextInt();   // inputs the "no." of lines that users want to enter
      int a,b, flag, count;
      String line[] = new String[t];
      String[] number=new String[2];
  
      for(int i=0; i&lt;t; i++){
          line[i] =st.nextLine();
      }
  
      for(count=0; count&lt;t; count++){
          number  = line[count].split(" ");
  
          a = Integer.parseInt(number[0]);
          b = Integer.parseInt(number[1]);
  
          for(int i=a; i&lt;=b; i++){
              for(int j=2; j&lt;=i; j++){
                  if(i%j==0){
                      if(i==j)
                         System.out.println(i);
                      else break;
                  }
              }
          }
  
          System.out.println();
      }
  }
  }   
  </code></pre>
  
  <p><strong>Error:</strong> The code when submitted, produces RuntimeException on spoj.com, although it works completely fine on my system.</p>