Split the main function into pieces

Have there be a scanning function that contained the
previous file scanning logic, then a validating function
that did the checking logic and then have the main function
call into those functions instead of containing all the
same logic in its own function.

Change-Id: Ie35665a016164122be294fee41e7ce54605d832e