program: dereference old line before encoding new line

the old line being replaced should be dereferenced before encoding new
line to possibly free dictionary entries before new entries are added so
that the new entries use the slots of the old entries

this change affected the indexes of some operands when lines were
replaced in encoder test 2, both expected encoder and recreated output
files were updated