Close input stream on edge case.
Merge pull request #534 from square/dimitris/close-stream

Close input stream on edge case.