read via stream and replace values instead of reading all the contents to a string and then replacing it