Hey There,
Do you have any error output you can post or does it just die quietly? Also, if you're running this in cron, the problem might be with it finding one of the commands in your cat to mail pipe - perhaps fully qualifying uuencode like you've fully qualified mailx would do the trick?
I don't think the EOF is causing you the issue, since that should complete the write to the file and looks like it's in perfect sequence.
ANother thing you can try is to put the
cat $file | uuencode $file | /usr/bin/mailx -s "TEST" "joe.blogs@hotmail.com" line in an entirely separate script and call it from this script. That would definitely tell you if problem is just on this one line or if any other part of your script is influencing it.
Hope some of that helped :)
, Mike