tempfile is replaced with mktemp