Ensure StreamWriter is disposed before passed-in-Stream is disposed to p...

...revent data loss (#241)