(Solved)-Reading SD-Card data through TCP (Ethernet Shield + SD-Card)

Do you know why and how to fix it ?

Yes. It is happening because the delay() causes the value returned by client.available() to change, since more time is allowed for data to arrive.

The data that the server is sending needs to be packeted. That is, there needs to be (and may already be) something that defines the end of a value. You might have the server append a ! after the value, or a carriage return and/or line feed (though it is quite possible that the CR/LF are already appended).

Then, you simply need to read whatever is ready to be read, appending it to an array, until the end of packet marker arrives. When that happens, open the file, write the data, close the file, reset the index and NULL the array.