fixed added file overwrite loop