Corrected make_dir to use temp files