Added option to write to file.