Just in case anyone else has this problem in the future, the cause was the fact that I was using the same input stream as my output stream (first two parameters of the function).  Another thing I learned is that the block encryption is performed in blocks of 32,676 bytes.  So if you are using this function you can use a buffer of that size for optimal performance on the receiving side.