Fix infinite-loop in temp-dir