I think you've got your brackets backwards. >> tells it to append to the HERE file, not read from a here document. And since it never reads the here document, it just hangs reading on STDIN instead. (For future reference, "hangs" is a much more useful description than "doesn't work", which could mean nearly anything...)
If it ever got beyond that it'd consider 'text' and 'HERE' on subsequent lines to be syntax errors.
#!/bin/sh
read text
ex $1 <<'HERE'
a
text
.
wq
'HERE'
The only thing that has to be done now is that the text given by the users should be put in the file. But ex just puts the word 'text' in it instead of the text given by the user.