Fix memory leak
Remember closed streams