fixed the file.tell() conflicting with file.next() issue