make sure to always close input stream