diff --git a/src/Verify/IoHelpers.cs b/src/Verify/IoHelpers.cs index 7bb56f7469..9976a08006 100644 --- a/src/Verify/IoHelpers.cs +++ b/src/Verify/IoHelpers.cs @@ -238,16 +238,18 @@ public static async Task ReadStringBuilderWithFixedLines(string p public static async Task WriteStream(string path, Stream stream) { CreateDirectory(Path.GetDirectoryName(path)); - if (!TryCopyFileStream(path, stream)) + if (TryCopyFileStream(path, stream)) { - // keep using scope to stream is flushed - using (var targetStream = OpenWrite(path)) - { - await stream.SafeCopy(targetStream); - } + return; + } - HandleEmptyFile(path); + // keep using scope to stream is flushed + using (var targetStream = OpenWrite(path)) + { + await stream.SafeCopy(targetStream); } + + HandleEmptyFile(path); } #endif