Changed to using buffered writer instead of file stream.