When you reposition the file back to the beginning, to actually read the data I think you want:
fl.seekg(0,ios::beg);
rather than
fl.seekg(length,ios::beg);
edit:
After the read add this code:
if(f1.eof())
{
std::cerr << "Error reading file."
<< " Requested " << length << " bytes."
<< " Read " << f1.gcount() << bytes."
<< std::endl;
}
That should tell you how big your code thinks the file is (verify against actual file size), and whether f1 thinks the read went well.
Also you should open the file in binary mode by using the ios::binary mode flag when you open the file.