why this function returns null outstream
<p>this function when called in a loop is sometimes giving null as outstream while other times not .. any reason why ? i am writing the outstream into text file sometimes i get empty text file . why ? if i run the loop 20 times .. i sometimes get empty text file on 3 random occasions sometimes 4 or 2 random occasions. what should i do ?</p>

<pre><code>public void decrypt(InputStream in, OutputStream out) {
  try {
    // Bytes read from in will be decrypted
    in = new CipherInputStream(in, dcipher);

    // Read in the decrypted bytes and write the cleartext to out
    int numRead = 0;
    while ((numRead = in.read(buf)) &gt;= 0) {
      out.write(buf, 0, numRead);
    }
    out.close();
  }
  catch (java.io.IOException e) {
  }
}
</code></pre>
