You need to reset the file pointer using
file.seek(0)
before using
file.readlines()
again.
More Related Contents:
- How to read a file line-by-line into a list?
- Why can’t I call read() twice on an open file?
- A non-blocking read on a subprocess.PIPE in Python
- Confused by python file mode “w+”
- How to use StringIO in Python3?
- How to open a file using the open with statement
- How to write to a CSV line by line?
- Reading file using relative path in python project
- What exactly is file.flush() doing?
- Python multiprocessing safely writing to a file
- Load data from txt with pandas
- Beginner Python: Reading and writing to the same file
- Read a small random sample from a big CSV file into a Python data frame
- Reading two text files line by line simultaneously
- How to read bits from a file?
- How to create in-memory file object
- Break string into list of characters in Python [duplicate]
- How to update/modify an XML file in python?
- Python code performance decreases with threading
- parsing a tab-separated file in Python
- ValueError : I/O operation on closed file
- IPython: redirecting output of a Python script to a file (like bash >)
- Tkinter GUI, I/O & Threading: When to use queues, when events?
- Reading a file using a relative path in a Python project
- When should I ever use file.read() or file.readlines()?
- Why is `with open()` better for opening files in Python?
- How to read records terminated by custom separator from file in python?
- Reading a File Line by Line in Python [duplicate]
- In Python, is read() , or readlines() faster?
- How to silence “sys.excepthook is missing” error?