I'm stuck on this after many attempts, I have an array of items and I'm trying to output this to a file but the problem is that it writes all at once and ignores newline. I'm beginning to wonder if rebol even has such a simple ability. file1.txt contains multiple lines
myArray: []
foreach line read/lines %file1.txt [
append myArray line
]
write %file2.txt myArray
this does not work, everything is written on to one line
fp: open/new %file2
foreach line myArray [insert fp line]
close fp
Neither does that work "cannot use insert on port!"
I am not trying to copy a file, The above is just a demonstration of what i'm trying to do.
Rebol keeps newlines as they are. But after reading with read/lines you just get a block of items without the newlines. If you want a block of items written as lines separated by newlines, you should write them again with the refinement write/lines and Rebol adds the newlines again.
myArray: []
foreach line read/lines %file1.txt [
append myArray line
]
write/lines %file2.txt myArray