make replace() method more generic (i.e. don't pass in or modify the file)