I'm trying to constantly update a file with the latest data (active proxis Ip and ports) by appending the new proxy at the bottom of the text file, and I want to delete the first line (It will be basically like scrolling from down up with all the latest proxies ips available). Counting the lines and appending the latest proxy it's not a problem and the code works, however I'm having trouble deleting only the first line without deleting (overwriting the entire text file)
This is my code:
proxy_list = ['proxy1','proxy2','proxy3','etc','etc'] # List of tested proxy
for proxy in proxy_list:
number_of_lines_in_file = sum(1 for line in open('proxies.txt'))
if number_of_lines_in_file >= 30:
with open('proxies.txt', 'w',encoding='utf-8') as update_new_proxies_file:
for index, line in enumerate(proxy.strip()):
if index == 1:
update_new_proxies_file.write(proxy)
This however deletes/overwrite the entire text file.
Is there anyway to simply delete the first line only without deleting all the other below content?