Bug fix stream is not closed