[The code's too big to put in this message I'm going to try putting it in a separate message]
Which Arduino are you running this on? The 328-based Arduinos have 2K of SRAM. The SD library needs 1/4 of that for the buffer to read from/write to the SD card.
Aside from the code being less elegant and hogging memory do you think that is actually part of the execution problem?
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16