Fix bug in tempfile deletion.