         search-results (search-multiline-string contents settings)
         with-file-results (map #(assoc-in % [:file] f) search-results)]
     (doseq [r with-file-results] (save-search-result r))))
-
-(defn matches-any-pattern [s pp]
-  (some #(re-find % s) pp))
-
-(defn any-matches-any-pattern [ss pp]
-  (some true? (map #(matches-any-pattern % pp) ss)))
-
-(defn linesmatch [lines inpatterns outpatterns]
-  (and
-    (or
-      (empty? inpatterns)
-      (any-matches-any-pattern lines inpatterns))
-    (or
-      (empty? outpatterns)
-      (not (any-matches-any-pattern lines outpatterns)))))
-
-(defn linesbefore-match [linesbefore settings]
-  (linesmatch linesbefore (:in-linesbeforepatterns settings) (:out-linesbeforepatterns settings)))
-
-(defn linesafter-match [linesafter settings]
-  (linesmatch linesafter (:in-linesafterpatterns settings) (:out-linesafterpatterns settings)))
 
 (defn search-line-for-pattern
   ([linenum line linesbefore linesafter p settings]

                       line
                       linesbefore
                       linesafter)]
          (if (:firstmatch settings)
            [result]
            (concat [result] (search-multiline-string-for-pattern s m
              endmatchindex startlineindices endlineindices settings)))))
      [])))

(defn search-multiline-string [s settings]

        search-results (search-binary-string contents settings)
        with-file-results (map #(assoc-in % [:file] f) search-results)]
    (doseq [r with-file-results] (save-search-result r))))

(defn matches-any-pattern [s pp]
  (some #(re-find % s) pp))

(defn any-matches-any-pattern [ss pp]
  (some #(not (= % nil)) (map #(matches-any-pattern % pp) ss)))

(defn linesmatch [lines inpatterns outpatterns]
  (and
    (or
      (empty? inpatterns)
      (any-matches-any-pattern lines inpatterns))
    (or
      (empty? outpatterns)
      (not (any-matches-any-pattern lines outpatterns)))))

(defn linesbefore-match [linesbefore settings]
  (linesmatch linesbefore (:in-linesbeforepatterns settings) (:out-linesbeforepatterns settings)))

(defn linesafter-match [linesafter settings]
  (linesmatch linesafter (:in-linesafterpatterns settings) (:out-linesafterpatterns settings)))

(defn get-newline-indices [s]
  (map first 
