while feof(sub_tag)==0
sub=fgetl(sub_tag);
[tag,replacement]=strtok(sub); %to create separate arrays for the tag and replacement
tag=lower(tag);
replacement=strtrim(replacement);
end
That code is throwing away all of the tags and replacement information, except for the very last one. Even then, in some circumstances you throw away the last one as well, as feof() is not guaranteed to be true when you have just positioned after the last newline in the file; in traditional POSIX file semantics, feof() would not be true in that situation, leading to an empty fget() result.
