Problem Description:
I am encountering a problem trying to remove my item from my list.
The list was previously written to a text file using call-with-output-file and is now being read using call-with-input-file.
After reading, the list looks like this: ("a" "b" "c").
The element should be removed with remove.
Code:
Read/Write:
(define lst
(call-with-input-file "todo.txt"
(lambda (des)
(read des))))
(call-with-output-file "todo.txt" #:exists 'update
(lambda (out)
(write lst out)))
Removal:
[(equal? action "remove todo")
(display (~a "Choose an ToDo to remove:\n" lst "\n"))
(remove (string-trim (read-line)) lst)
(call-with-output-file "todo.txt" #:exists 'update
(lambda (out)
(write lst out)))
(display "Removed.")]))
Expected Behavior:
I expect the program to write the new list in my text file.
Actual Behavior:
My program overwrites the file with the same list as before (no deletion, no error).
Thanks for any help! -Till