back and forth between Ethernet and SD on Wiznet 5100 shield

    pinMode(10, HIGH);
    pinMode(4, LOW);

Did you mean to use digitalWrite?