I use the following code segment to read a file in python:
with open (\"data.txt\", \"r\") as myfile: data=myfile.readlines()
Input fil
To join all lines into a string and remove new lines, I normally use :
with open('t.txt') as f: s = " ".join([l.rstrip() for l in f])