> if not FileExists( $WanIpFileName )  {
>     $WanIpFileName.IO.open(:w);
>     spurt "$WanIpFileName", "New File Opened";
> }

Afaik, depending on how you choose to look at things,
there's a doc error (doc for `spurt` doesn't mention that
it opens the file it's spurting to), and/or behavior due to
your Windows file system / account settings that leads
to the issue you see, and/or a bug in your code.

Let me explain. Here's what the code does:

1. Opens the file with `$WanIpFileName.IO.open(:w);`
if it doesn't already exist.

2. Opens the file with `spurt` and writes to it.

And that causes the behavior you see.

Presumably, on your system/setup, doing those two things
fails because the second open fails due to the first one.

So it succeeds the second time around because the file
already exists (though blank) and the `spurt` goes ahead.

I'd argue that the bug is ultimately in your code, perhaps
due to you not realizing that `spurt` opens the file it spurts
to, because the doc doesn't say so.

Whichever way one looks at it, there's no bug in Raku(do).

--
love, raiph

Reply via email to