Move index_file out from main() into its own function.