change tmpfile scope, and delete file *after* we publish