Call to undefined method ::rewind()