fixed name versus names differences in the write_flags function.