To my eyes the second for loop should be entered but it never does. Why is this? It's like the file is empty but I can assure you it's not.
def remove_none():
# remove contents of temp.txt
file = open('temp.txt', 'w')
file.truncate()
file.close()
with open("temp.txt", "a") as temp:
with open("temp_copy.txt") as temp_copy:
num_of_lines = 0
other_IPs = 0
# count the number of lines in temp_copy.txt
for _ in temp_copy:
num_of_lines += 1
other_IPs = num_of_lines-3
print "\nThere are {} IP's excluding router and you.\n".format(other_IPs)
count = 0
os.system("cat temp_copy.txt")
**# this is the second for loop**
for line in temp_copy:
count =+ 1
print count
if count == 1:
# run this on the first line
temp.write(line)
elif count == num_of_lines:
# run this on the last line
# remove the last line
pass
else:
# run this on every other line
line = line[4:]+"\n"
temp.write(line)