Move stuff from main() to new build_output_filename(); bugfix +1