I've seen this before - usually it's because the StreamWriter is throwing an Exception. You'd think that this would cause an exception in your script, but I've seen cases where it's throwing non-terminating exceptions, so your script doesn't ever receive it.
After running the block of code, try getting the last exception details:
$Error[0].Exception | Format-List * -Force
If there's an exception, it should help you figure out exactly what is causing the problem. My guess would be that it's a permissions issue.