You're still going need to read the entire file, but you don't have to process
every line, since you need just first N lines.
(defun your-read-lines (file n)
"Return first N lines of FILE."
(cl-loop repeat n
collect (prog1 (buffer-substring-no-...