So the answer is to generalize the logic that checks for temporary folders as such:
if (grepl("Rtmp", getwd()))
instead of:
if (grepl("Temp", getwd()))