be sure to close stream to avoid exception when clean files