closing streams correctly to avoid resource leaks
Merge pull request #218 from bertpassek/master

closing streams correctly to avoid resource leaks