Also, you should probably move the inputstream into the with-open as well, so it gets closed