eof detection in buy.cpp and sell.cpp