Don't write over end of the Palette array

It was checking for EOF before the file read, so it would always write
one extra color than is stored in the palette (and therefore wrote
beyond the end of the allocated array)