Writing data to file.