> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/f/file-input/output.md).

# Output

If it is okay to have a temporary copy of the entire file in memory:

```perl
spurt "output.txt", slurp "input.txt";
```

Otherwise, copying line-by line:

```perl
my $in = open "input.txt";
my $out = open "output.txt", :w;
for $in.lines -> $line {
    $out.say: $line;
}
$in.close;
$out.close;
```
