How to read all the lines of a file into a list and remove trailing newlines?