Since you are getting the regular expression pattern via an argument I would first check that searchPattern is what you expect. Shells can do funny things with arguments containing special characters. Also, is it possible that the quoted strings in the files contain escapes? For example if a file contains the text "hello\n" would you consider that 6 characters or 7?
-- http://mail.python.org/mailman/listinfo/python-list