Should fix the test case failure. Putting a null check around
streamWriter.