python爬取网页数据后json加载报错,如何解决?

python 爬取网页数据保存到了本地txt文件,这里没有任何问题,然后我用json.loads()加载时报错了
部分代码内容:

for i in range(10):
url = baseUrl.format(str(i+1))
res = requests.get(url, headers)
print(res.status_code)
infoStr = res.text
with open(sourcePath, 'a+', encoding='utf-8') as f:
f.write(str(infoStr) + '\n')
f.close()

以上运行都正常,下面就报错了

file = open(sourcePath)
for line in file:
returnValue = json.loads(line)

错误内容:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

你检查一下你的txt数据是完整的json格式数据吗

f.write(str(infoStr) + '\n')
你写文件的时候都不是用json dumps写入的。
用json 读肯定失败呀。