Unless "text.txt" is somehow too large, you should read the whole file into memory and do your comparison from there. Hitting secondary storage is expensive and should be avoided.
@ LB: Why would you work with the file on the disk? Why not work with it in memory like a sane person would? Even if the file is too large I would suggest a file map over using the "std::istream.seek()" function.
my aim is to read a record from text.txt in to fs and compare it with other records of text.txt by read
He can read the record he wants, then seek to the beginning and read the whole file normally. Basically the same as what you're saying but without the requirement to store everything in memory (it is now optional).