https://stackoverflow.com/questions/53799391/input-file-example/53799514#53799514
16 Dec 2018, Sun
You are missing number of things in your code, actually that is not a good way to get the file contents in one line.
This is a simple example that will give you both, a single line and a list of words.
raw_file.txt
My intension was to tell you the secret of my life and I wish you will like it.
in_one_line.py
import re
with open("rw_file.txt", encoding="utf-8") as f:
lines = f.read();
s = re.sub(r'\s+', ' ', lines)
words = s.split()
print(s)
# My intension was to tell you the secret of my life and I wish you will like it.
print(words)
# ['My', 'intension', 'was', 'to', 'tell', 'you', 'the', 'secret', 'of', 'my', 'life', 'and', 'I', 'wish', 'you', 'will', 'like', 'it.']