Added fclose() to close socket
Added comments and fixed appearance