Corrupted files generated by Arduino with SD library. How to avoid that?
Both the SD-card interface and the WizNet interface share the same SPI interface of the microcontroller. There is a known bug (or rather a terrible design neglect) in the Arduino SPI software library in this regard, occasionally causing data corruption. It's not interrupt-safe. The issue is explained and fixed here:

http://www.dorkbotpdx.org/blog/paul/spi_transactions_in_arduino

It accomplishes this by allowing the library user to enclose access to SPI with guard methods:


  In a nutshell, SPI.beginTransaction() protects your SPI access from other interrupt-based libraries, and guarantees correct setting while you use the SPI bus. 


Oh, the depth of the issue means you have to fix/rewrite everything that takes advantage of the SPI library. Arduino use-case has evolved upwards in complexity from very simple projects, and libraries might take a while to fully reflect this transition.