Since we're doing the same file scanning in two places, please factor out into a method.