Updated bash script to use mktemp.