Added function to write to disk.