The problem is, that you are creating broken json file.
If you take tool like jsonlint
and let it check your "index.json" file, you will see the problem in json file format.
Your code, creating the JSON file is using dic.write
in a loop, so it is appending pieces of JSON string, which are likely to be valid one by one, but not concatenated.
The solutions are:
Write resulting JSON file in one shot
If you can afford it, create complete dictionary content first in memory (probably in form of a dictionary), and finally, when you have it complete, dump it into json file just once.