Problema C ++ eof (): ¿nunca devuelve verdadero?

Así que estoy tratando de leer este archivo. Parece que todo debería funcionar, pero durante el tiempo de ejecución, el programa agota el tiempo y deja de funcionar, y tengo que cerrarlo. Que esta pasando? Sospecho que la prueba oef () nunca vuelve a ser verdadera y sigue buscando más en el archivo. No tengo que arrastrar líneas vacías en el archivo de texto. He intentado depurar esto como loco. No puedo encontrar nada malo, pero todavía se niega a funcionar.

Pet** petArray;

ifstream textFile2;
textFile2.open("pets.txt");

int i = 0;
string temp;
int tmpNum = 0;

if (textFile2.is_open())
{
    while (!textFile2.eof())
    {

        getline(textFile2, temp);

        petArray = new Pet*[arraySize];

        if (temp == "Dogs" || temp == "Cats" || temp == "Iguanas" || temp == "Pigs")
        {
            if (temp == "Dogs") tmpNum = 0;
            if (temp == "Cats") tmpNum = 1;
            if (temp == "Iguanas") tmpNum = 2;
            if (temp == "Pigs") tmpNum = 3;
            temp == "";
        }
        else
        {
            if (tmpNum == 0)
            {
                petArray[i] = new Dog(temp);
                cout << "Dog " << temp << " added" << endl;
            }
            if (tmpNum == 1)
            {
                petArray[i] = new Cat(temp);
                cout << "Cat " << temp << " added" << endl;
            }
            if (tmpNum == 2)
            {
                petArray[i] = new Iguana(temp);
                cout << "Iguana " << temp << " added" << endl;
            }
            if (tmpNum == 3)
            {
                petArray[i] = new Pig(temp);
                cout << "Pig " << temp << " added" << endl;
            }
            arraySize++;
        }

        i++;
    }
}

Aquí está el formato del archivo de texto:

Dogs
d1
d2
Cats
c1
c2
Iguanas
i1
i2
Pigs
p1
p2

¿Alguna sugerencia?

Respuestas a la pregunta(2)

Su respuesta a la pregunta