I'd do this first, then all the _write_flat_fil(some_uep_calls) so this isn't buried in the midst of write_flat_file