you wtite last message twice. add check of file end write after massage reading