Fix file scanning logic.