Added function to write to file.