fix for not closed stream