Extract write_setup_file(). No functional change.

Test output differs only by the line numbers of the TODO items.