Don't use InputStream.available() to determine how much to read.

I misunderstood the contract of this method, it will often return 0 on the Android implementation.