fixed the bug that used to overwrite items in file