Changed socket end to write