Closes #2, added finally; closing IO streams was done earlier