title: for loop with try-catch stopping at first index
body: <p>String[] urls contains URLs as strings (code reads inputStream of each URL).</p>
  
  <p>I cannot iterate through any indices of String[] URLs after the first index (index 0) even though the exit condition in the for loop is 'i &lt; urls.length'.</p>
  
  <p>NOTE: It works when String[] urls size is 1. I'm testing it on when String[] urls size is 2, in which case only the first index but not the second is iterating. And I'm only interested in what's between the <code>&lt;body&gt;</code> blocks (hence <code>if (s.contains("&lt;br&gt;")</code>)</p>
  
  <p>Any ideas as to why this is happening? </p>
  
  <pre><code>public void readData(String[] urls) {
      for (int i=0; i&lt;urls.length; i++) {
          System.out.println(i); //for a String[] urls of size 2, only 0 gets printed. 
          //I want both 0 and 1 printed
  
          String str="";
  
          try { 
              URL url=new URL(urls[i]);
              URLConnection conn=url.openConnection();
              BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  
              String s;
  
              while (( s = in.readLine())!=null) {
                  if (s.contains("&lt;br&gt;")) {
                      str += s;
                  }
              }
          } catch(Exception e) {
              e.printStackTrace();
          }
            System.out.println(str); // for String[] urls of size 2, 
            //only the inputstream of urls' first index gets printed.
            //I want both to be printed
      }
  }
  </code></pre>
  
  <p>EDIT:
  This is the sample of an html I want to read (what each element of String[] urls brings to)</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
  Title
  &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Name1 Age1 Hometown1&lt;br&gt;
  Name2 Age2 Hometown2&lt;br&gt;
  Name3 Age3 Hometown3&lt;br&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>