# create file descriptor 3 for writing to a temporary file so that
When it gets closed (which the kernel does automatically when the process exits) the filesystem deletes the file. The file keeps available (for the script not really for other processes but /proc/$PID/fd/$FD is a work-around) as long as the file descriptor is open. You can make sure that a file is deleted when the scripts exits (including kills and crashes) by opening a file descriptor to the file and deleting it.