The last round of changes left this function (`process-file`) pretty ugly.  I am at a loss for how to improve it.  Suggestions welcome.