.sub('', self._orig_content.rstrip('\n')) code example Example: python removing \n from string line = line.strip('\n') line = line.strip('\t')