Fixed a bug where an InputStream wasn't being closed when it was finished with.