title: How to read n lines from a file in clojure
body: <p>I want to read first n lines from a file using clojure. Here is my code:</p>
  
  <pre><code>(defn read-nth-line [file]
    (with-open [rdr (reader file)]
      (loop [line-number 0]
        (when (&lt; line-number 20)
              (nth (line-seq rdr) line-number)
              (recur (inc line-number))))))
  </code></pre>
  
  <p>but when I run</p>
  
  <pre><code> user=&gt; (read-nth-line "test.txt")
  
   IndexOutOfBoundsException   clojure.lang.RT.nthFrom (RT.java:871)
  </code></pre>
  
  <p>I have no idea why I got such an error.</p>