separate checkFileExtension from search; search() should only search the pattern in a given file, rather than deciding whether to search that file.