You should post your whole sketch as making comments on a snippet can be misleading .
However based on the small amount of code you have posted it seems obvious that you have the client.write in the wrong place and that it should be after the if block rather than within it. There should also be a check after the client.connect to make sure it has worked. The buff won't be lost at that point but it will not be sent according to the code snippet whether it is lost after we cannot tell.