New implementation on how data files are overwritten.

Changed from file_put_contents to fwrite() and fopen() format.