Fixed filename bug when metadata.json did not exist and was created for the first time