Added ability to write to file.