Modify script to write to file.