commented line remove
eof -> eof_flag
fix write