removed EOF, and added length variable.