Close file after read complete
break loop after close socket (or it's not necessary?)