Beware of line termination conventions across operating systems !
- Windows: CRLF (
\r\n) - Linux and other Unix: LF (
\n) - Old Mac: CR (
\r)
You are probably mistaken because the double new line you are looking for is in a Windows-encoded text file and will display as \r\n\r\n, rather than \n\n.
The function repr()will tell you for sure that you are ending:
>>> mystring =
>>> repr(mystring)
"'\\nmulti\\nline\\nstring '"
, ?
with open(file.txt, 'r') as f:
for line in f:
print (line)