You may want to call the StreamWriter Flush() method if your application is closing down before the StreamWriter is flushed. That said, I agree with @gilliduck, you would be better off using a logging frame work.
https://learn.microsoft.com/en-us/dotnet/api/system.io.streamwriter.flush?view=net-9.0#system-io-streamwriter-flush