Loadfile loads a file as an object (which can be deleted), dofile just runs the script as though its all one script rather then multiple.
If you do use dofile, you MUST use it properly. The file that you dofile must have a way to reach the end of the script and finish.