You need to rewind the file pointer. That's how Unix files work. I forget the 
exact port operation you need, but it should be in the manual.

Sent with a Spark
On Apr 3, 2021, 5:23 PM -0700, Nicholas Papadonis 
<nick.papadonis...@gmail.com>, wrote:
> I'm using MIT Scheme 10.1.5 and am curious why the following code using 
> open-i/o-file is not working as I expected. Does anyone know what the issue 
> is?
> (define l "~/tmp0")
> (define x ''(a b (c d) e f))
>
> (let ((p (open-i/o-file l)))
>  (begin (write x p)
>     (flush-output p)
>     (let ((r (read p)))
>       (close-port p)
>       r)))
> ;Value: #!eof
> when I was expecting:
> ;Value: (quote (a b (c d) e f))
> When using open-input-file or open-output-file the results are expected:
> (let ((p (open-output-file l)))
>  (write x p)
>  (close-port p))
>
> (let ((p (open-input-file l)))
>  (let ((r (read p)))
>    (close-port p)
>    r))
> ;Value: (quote (a b (c d) e f))
>

Reply via email to