change the name of "gen_output" to "write_output"