Explanation
If the read() method is called two times, it returns an empty string the second time.To avoid that, we call the read() method once and store its output in a variable:
content = file.read()
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.
