forward port of fix for fold_file_loop

2.0 version of #172 
This comment is now wrong since the funs are arity 5.