use existing open fd from mkstemp instead of re-opening the file