correctly check result of fwrite

This fixes a thinko in the check of fwrite's result.
fwrite returns the number of elements written, and we'd
requested just one element.
This also changes the temporary directory's name.