So far, I've used the range function which works when I simply print the lines imported from the URL but when I try to save them to a txt file it only saves line 5 (or whatever the last number of the range is).
target_url="random URL"
request = requests.get(target_url)
text=request.text
lines=text.split("\n")
for i in range(1, 5):
savefile = open('c:/Users/ghostsIIV/Desktop/examplefile.txt', 'w')
savefile.write(lines[i])
savefile.close()