Factored out file finding logic.