Q:

File reading and regex - Python

I read a file which has a line : Fixes: Saurabh Likes python
I want to remove the Fixes: part of above line.  I am employing regex for that
but the snippet below returns output like 
Saurabh Likes python\r

I am wondering where \r is coming from.  I tried all strip options for removing it like rstrip(), lstrip(), etc.  But nothing worked.  Could anybody suggest me the way to get rid of \r. 
patternFixes ='\s*'+'Fixes'+':'+'\s*'
matchFixes= re.search(patternFixes,line, re. IGNORECASE)
        if matchFixes:
                    patternCompiled = re.compile(patternFixes)
                    line=patternCompiled.sub("", line)
                    #line=line.lstrip()
                    relevantInfo = relevantInfo+line
                    continue

Thanks in advance! 
-Saurabh

A:

Suggestion to get rid of \r:
I suppose you have opened your file using open(filename).  Following the manual of open:

If mode is omitted, it defaults to 'r'. ...  In addition to the
  standard fopen() values mode may be 'U' or 'rU'.  Python is usually
  built with universal newlines support; supplying 'U' opens the file as
  a text file, but lines may be terminated by any of the following: the
  Unix end-of-line convention '\n', the Macintosh convention '\r', or
  the Windows convention '\r\n'.  All of these external representations
  are seen as '\n' by the Python program. 

So, in short, please try to open your file using 'rU' and see if the \r vanishes:
with open(filename, "rU") as f:
    # do your stuff here. 
    ...

Does the \r vanish in your output? 
Of course your code looks rather clunky, but other have already commented on this part.