I have a text file like this,
#: Two before narrow not relied how except moment myself.
%: So gate at no only none open. Betrayed at properly it of graceful on
Dinner abroad am depart ye turned hearts as me wished.
#: Ham followed now ecstatic use speaking exercise may repeated Himself he evident oh
greatly my on inhabit general concern.
%: Therefore allowance too perfectly gentleman supposing man his now
Families goodness all eat out bed steepest servants.
I only want to print the lines that starts with '#:' but I want the full sentence rather one line, here's what I have done,
f = open("text.txt", "r")
for line in f:
if line.startswith("#:"):
print(line)
output:
#: Two before narrow not relied how except moment myself.
#: Ham followed now ecstatic use speaking exercise may repeated Himself he evident oh
Expected output:
#: Two before narrow not relied how except moment myself.
#: Ham followed now ecstatic use speaking exercise may repeated Himself he evident oh
greatly my on inhabit general concern.
Notice that the second '#:' sentence only contains one line rather than the whole sentence, if I use next(f) it will also consider sentence starting with '%:'. Any ideas?