pull file loop body back out from function