Add end of file clause.
Port the rest of MemBuffer unit.