hey-ho beautiful people!!

Can someone give me a little help understaning 'XOR'??

I'm trying to make an encryption program using it but i'm having inexplicable
troubles. You see my code works fine using 'AND'and 'OR' but 'XOR' gives
me a world of weirdness!!

Using the 'XOR' the loop controling the character encryption seems to terminate
after only three or four loops, so obviously only three or four characters are
actually encoded leaving my little program rather ineffective.
here's my code

Code:
for(i=0;i<strlen(filec)-2;i++)                       /* filec  is the line i want to encode*/
{
  
    filec[i]=filec[i]^keyfile[i];                 /* keyfile is the key copied again and again to */                        
                                                                /*  match the lines length */ 
    fprintf(ptr,"%c",filec[i]);
          
}
I'm sure this problem results from a lack of education on my part so could someone
help me out and explain it?

oh and if anybody knows of any good books on encryptions let me know!?!