sane logic in for-loop in do_file()