add unique numbers to temporary file names

This avoids problems when multiple files with the same name in different
directories are specified on the commandline.