Ensured the the `prev_dir` file is always updated