Correct resource closing

If we open a stream, it's our responsibility to close it.