def _run_lint_on_file(file_path,
                      linter_functions,
                      tool_options,
                      fix_what_you_can):
    """Run each function in linter_functions on filename.

    If fix_what_you_can is specified, then the first error that has a
    possible replacement will be automatically fixed on this file.
    """
    with io.open(file_path, "r+", encoding="utf-8") as found_file:
        file_contents = found_file.read()
        file_lines = file_contents.splitlines(True)
        try:
            errors = lint(file_path[len(os.getcwd()) + 1:],
                          file_contents,
                          linter_functions,
                          **tool_options)
        except RuntimeError as err:
            msg = ("""RuntimeError in processing """
                   """{0} - {1}""".format(file_path, str(err)))
            errors = [("polysquarelinter/failure",
                       LinterFailure(msg, 0, None))]

        if fix_what_you_can:
            for error_index, error in enumerate(errors):
                if error[1].replacement is not None:
                    _apply_replacement(error, found_file, file_lines)
                    errors[error_index] = (error[0],
                                           LinterFailure(error[1].description +
                                                         " ... FIXED",
                                                         error[1].line,
                                                         error[1].replacement))
                    break

        return [FileLinterFailure(file_path, e) for e in errors]
Run each function in linter_functions on filename.

    If fix_what_you_can is specified, then the first error that has a
    possible replacement will be automatically fixed on this file.