Obviously, this procedure assumes you are using the LaTeX or SliTeX format. Plain TeX users can `trick' 4TeX by including the text % \begin{document} in their main file. The TeX compiler will not stumble on it because it is a comment. The \end{document} command inserted by 4TeX should work normally, provided that \end has not been redefined.