This seems to work.
Code:
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int
main()
{
ifstream infile("test.txt");
if (!infile)
{
cerr << "Error opening file test.txt." << endl;
return 1;
}
unsigned short consequtive_newlines_count = 0;
string line;
bool positives_string_found = false;
while (getline(infile, line) && consequtive_newlines_count < 3)
{
if (line.find("Positives") != string::npos)
{
positives_string_found = true;
}
if (positives_string_found)
{
cout << line << endl;
if (line.empty())
{
++consequtive_newlines_count;
}
else
{
consequtive_newlines_count = 0;
}
}
}
It assumes that three newlines have to be on an otherwise empty line, i.e. three empty lines will break the output. It doesn't count the newline just before an empty line.
For the following file test.txt
Code:
/////////////
Score = 58.2 bits (139), Expect = 9e-08
Identities = 27/141 (19%), Positives = 65/141 (45%)
Query: 9 NVGNIVLRLTNIGLKIMKVGPKIPNVRPNVGNIGPIITKVGLTCSNIGPNITNVGLKLTN 68
N + L + +G+ + VG + N+ +G + VG+ S +G + +G+ ++
Sbjct: 431 NASGVGLTASGMGMNMSGVGLTASGMGMNMSGVGLTASGVGMNMSGVGLTASGMGMNMSG 490
Query: 69 LGLKLTNLGLKLTNIGPKIMKVGPQRPNVGPNVGNIGPNITNIGPKVMKVDPEIPNIGPN 128
+GL + +G+ ++ +G +G VG +G N++ +G + + +G
Sbjct: 491 VGLTASGMGMNMSGVGLTASGMGMNMSGVGLTASGMGMNMSGVGLTASGMGMNMSGVGLT 550
Query: 129 VGNIGPKITNLGHKGTSVGLN 149
+G ++ +G + +G+N
Sbjct: 551 ASGMGMNMSGVGLTASGMGMN 571
////////////////
the output is
Code:
$ ./runme.exe
Identities = 27/141 (19%), Positives = 65/141 (45%)
Query: 9 NVGNIVLRLTNIGLKIMKVGPKIPNVRPNVGNIGPIITKVGLTCSNIGPNITNVGLKLTN 68
N + L + +G+ + VG + N+ +G + VG+ S +G + +G+ ++
Sbjct: 431 NASGVGLTASGMGMNMSGVGLTASGMGMNMSGVGLTASGVGMNMSGVGLTASGMGMNMSG 490
Query: 69 LGLKLTNLGLKLTNIGPKIMKVGPQRPNVGPNVGNIGPNITNIGPKVMKVDPEIPNIGPN 128
+GL + +G+ ++ +G +G VG +G N++ +G + + +G
Sbjct: 491 VGLTASGMGMNMSGVGLTASGMGMNMSGVGLTASGMGMNMSGVGLTASGMGMNMSGVGLT 550
Query: 129 VGNIGPKITNLGHKGTSVGLN 149
+G ++ +G + +G+N
Sbjct: 551 ASGMGMNMSGVGLTASGMGMN 571
$