The code seems to be working fine. But after running the script nothing is being saved in the files. The files stay empty afterwards too.