solved problem with opened stream when saving objects