This is my code to delete last line of file but after rewriting it to the same file there is an extra empty line that exist.
lines = open('file.csv', 'r').readlines()
del lines[-1]
open('file.csv', 'w').writelines(lines)
Notice that initial file has two lines:
Orange[1st line of csv] Blue[2nd line of csv]
Notice that the last text/line of file is deleted, but there is extra empty line:
Orange[1st line of csv] [2nd line still exist but empty]
My goal is to have that extra line to be deleted. Thank you in advance!