Add timeout to .eof? otherwise it could hang forever