open done.txt file once before chdir to avoid symlink problems