Fixed issue with file reading

Changed from list comprehension to while loop.