Having trouble checking for newline when reading file
<p>I'm trying to write a program to read a file of an unknown size / line size but I'm having some issues detecting the new line character.</p>

<p>When I run the program, it never reaches the end of the line point within the while loop in <code>readFile</code> and will just run constantly. If I run print each character, it prints out some unknown char. </p>

<p>I've tried setting <code>ch</code> to be an int value and typecasting to char for <code>\n</code> comparison. It's not reaching the <code>EOF</code> condition either so I'm not sure what is going on.</p>

<p>code:</p>

<pre><code>void readFile(FILE* file)
{
    int endOfFile = 0;
    while (endOfFile != 1)
    {
        endOfFile = readLine(file);
        printf("%d\n", endOfFile);
    }
}

int readLine(FILE* file)
{
    static int maxSize = LINE_SIZE;
    int currentIndex = 0;
    int endOfFile = 0;
    char* buffer = (char*) malloc(sizeof(char) * maxSize);
    char ch;

    do
    {
        ch = fgetc(file);
        if ((ch != EOF) || (ch != '\n'))
        {
            buffer[currentIndex] = (char) ch;
            currentIndex += 1;
        }

        if (currentIndex == maxSize)
        {
            printf("Reallocating string buffer");
            maxSize *= 2;
            buffer = (char*) realloc(buffer, maxSize);
        }
    } while ((ch != EOF) || (ch != '\n'));

    if (ch == EOF)
    {
        endOfFile = 1;
    }

    parseLine(buffer);
    free(buffer);

    return endOfFile;
}
</code></pre>

<p>If someone could help me that would be greatly appreciated because I have been stuck on this issue for quite some time. Thanks in advance.</p>