Delete a specific line from a file [duplicate]
Solution 1:
This line in the view()
function is your problem:
for line in f.readline():
readline()
reads in a single line. Since the for-loop is iterating over a string rather than a list of strings, it iterates over each character in the line, printing one character out at a time.
You're looking for this:
# Note that it's .readlines(), not .readline()!
for line in f.readlines():
Or, even better:
for line in f: