checking for existing files before overwriting