Hopefully fixed the server crashing if client disconnects in the middle of writing.