Task

Replace every occurring instance of a piece of text in a group of text files with another one.



For this task we want to replace the text   "Goodbye London!"   with   "Hello New York!"   for a list of files.




#lang transd
 
MainModule: {
    _start: (λ 
        (with files ["a.txt" "b.txt" "c.txt"] fs FileStream()
            (for f in files do
                (open-r fs f)
                (with s (replace (read-text fs) 
                        "Goodbye London!" "Hello New York!")
                    (close fs)
                    (open-w fs f)
                    (write fs (to-bytes s) (size s)))))
    )
}