Tcl tries to use mkstemp() but the current implementation in APE does not allow reading from the file. This sets the flags to open() as documented in various man pages. Other implementations also check errno==EEXIST after failure, to break the loop earlier. But that is probably overkill for that rare error condition.