Well, the message about id2 on more than one terminal is expected behaviour. Now, for the hanging, it looks as if the loop is not handling well the "here" document. That would explain it, because write reads standard input. Try again and when it stops, press "Ctrl-D". If it returns you to the prompt, then the "here" document is your problem.
Could you double check the closing of your here document? It has to be exactly the same as the opening, and you cannot use any spaces to indent it.