Fixed null pointer exception in text file writer.