Someone
written = 0
for each line in the tool table:
if this line is for the tool just input by the user:
write the information input by the user
written = 1
else:
write this line
if not written:
(the tool table didn't have an entry for this tool yet)
write the information input by the user