A generalized testing loop with file input