Python strip. can't strip newlines but using f.read()
Question: Such a simple action, but I canoot get this to work!!!..

If I have a file that has a number of lines containing text, I want to strip
all newlines and whitespace and have a single contigous string from the
contents of the file. I've written a very simple python script to do this but
it's not working and I cannot figure out where I'm going wrong. :/

file contents look like:

    
    
    1244X 2222 555
    141234X 
     2332X
    2354235X
    235235  X235 5233 5 523
    

code

    
    
    import sys file = sys.argv[1]
    with open(file, 'r') as infile:
     data = infile.read()
     clean_data = data.rstrip('\n')
     print clean_data
    

prints out:

    
    
    1244X 2222 555
    141234X 
     2332X
    2354235X
    235235  X235 5233 5 523
    

when I want;

    
    
    1244X2222555141234X2332X2354235X235235X23552335523
    

I have tried `strip()`, `strip(\n\r)` as well as `rstrip()`..

Obviously I'm doing something stupid, but please can someone point out the
problem?


Answer: 
    >>> with open('hello.txt') as f:
    ...     f.read().replace(' ', '').replace('\n', '')
    ... 
    '1244X2222555141234X2332X2354235X235235X23552335523'
    >>> 
    

Or:

    
    
    >>> with open('hello.txt') as f:
    ...     ''.join(f.read().split())
    ... 
    '1244X2222555141234X2332X2354235X235235X23552335523'
    >>> 
    

