read-lines/write-lines added by wasamasa on Tue Jul 13 09:12:37 2021

(import scheme)
(import (chicken base))
(import (chicken io))

(define (read-lines path)
  (call-with-input-file path
    (lambda (in)
      (read-list in read-line))))

(define (write-lines path lines)
  (call-with-output-file path
    (lambda (out)
      (for-each
       (lambda (line)
         (write-line line out))
       lines))))

(let ((lines (read-lines "/etc/passwd")))
  (write-lines "/tmp/lines" lines))