Updated write to file with new to string method.