Make the StreamWriter a property of WriteExtractedRecord and decompose the Write method with helper methods.