K&R Word Couting program in C 1.5.4 : I am referring K&R for learning C. I am not getting the desired output for the following code.

    #include<stdio.h>
    #define IN 1
    #define OUT 0
    main()
    {
        int c,nl,nw,nc, state;
        nl = nc = nw = 0;
        state = OUT;
        while ((c=getchar()!= EOF))
        {
            ++nc;
            if (c == '\n')
            {
                ++nl;
            }
            if (c ==' ' || c == '\n' || c == '\t')
                state = OUT;
            else if (state == OUT)
            {
                state = IN;
                ++nw;
            }
        }
        printf("%d %d %d", nc, nw,nl);
    }

I gave the following input

    the
    door is
    open

The output I obtained was

    17 1 0

Kindly tell me what's wrong in the code.