Mega with wiznet shield (wire hack)+thingspeak+sd problem

You're using String a lot. It has issues with a bug in the underlying memory allocation routines it uses. The symptom you have that your sketch works for a while and then fails suggests that this may be your problem. Try using C strings (arrays of char) instead.