'Printing file.read() doesn't display file content

I am not being able to understand why file.read() behaves differently when I save it in a variable. Here is the illustration:

with open("file.txt","r") as file:
    content=file.read()
    print(content)
    print("------")
    print(file.read())

And the output is:

a
b

------

So, the last line of the code is not printing anything out.

Anyone care to explain why?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source