Plug memory leak.

Spotted by Coverity's scan.
Use mkstemp.

I have no idea why I ever thought using tmpfile was a good idea...
Use -q consistently in the examples.