Multiple search/replace per line fixed.

Previously for each match I simply used the original string contents
from the start of the line until the index of the match and from the
end of the corresponding serialized string til the end of the original
string. This only updated the last match. This change incrementally
builds the new string for each match.