it could be simplier
while( !input.eof() )
{
// read message
if ( input.eof() )
break;
}
or you can write operator >> for market_message and use while( input >> market_message_object)

or 

calculate a file size and use this number to determine oef.