Split write_header up into smaller pieces

Translate_filename and write_file