revert changed done by b7056ee03269a6c7e23c5b95fdd5884e7937565a

moving the test outside the loop breaks the test for the filename (fn)