System for saving objects

Now my code look like this: pastebin.com/ZSLX1yRb, but I still have a problem. At this point, I don’t know why, but in the resulting file, after everything is done, the last js call is repeated in place of all previous JSONs.