Fixes #7 fileInputStream not closed properly
small code refactor