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.




class ReplaceAll {
  function : Main(args : String[]) ~ Nil {
    files := ["text1.txt", "text2.txt"];
    each(f : files) {
      input := System.IO.File.FileReader->ReadFile(files[f]);
      output := input->ReplaceAll("Goodbye London!", "Hello New York!");
      System.IO.File.FileWriter->WriteFile(files[f], output)->PrintLine();
    };
  }
}