SD card write very random, mostly not working

Made the code modifications

I suggest that you check with the fine folks at http://snippets-r-us.com for help with your snippets.