'end of file' unexpected

HI,
I was converting a .bat file to .sh file for unix

Code snippet

#!/usr/bin/sh
set -x
if [ "$1" = "" ] then
goto RegularBuild;
CURDIR="$1";
cd "$CURDIR";

:RegularBuild
echo "Checking for existing fip_help.properties in def/properties directory..."
if [ -f fip_help.properties ] then
rm -f fip_help.properties;

if [ -f ../../def/properties/fip_help.properties ] then
goto found;

echo "fip_help.properties not found in def/properties directory"
goto gen;

:found
echo "Found fip_help.properties in def/properties directory."
echo "Copying fip_help.properties from def\properties directory..."
cp ../../def/properties/fip_help.properties .
goto gen;

:gen
fip_help_gen.sh ../../xml/fip_navigation.xml ../../xsl/fip_popups.xsl
if [ ! -f fip_help.properties ] then
goto error;

echo "Copying fip_help.properties to def/properties directory..."
cp fip_help.properties ../../def/properties/ .
chmod 444 ../../def/properties/fip_help.properties
echo "fip_help.properties file placed in def/properties directory."
goto end

:error
echo "fip_help.properties file generation failed"
goto end

:end
echo "completed"

set +x

End of code snippet

Could someone point me where I went wrong...
Thanks,
Sreeku

It's still waiting for the "then" for the first if. And after that, it will want the "fi". The if syntax requires then to be on a separate line, or have a semicolon in front; and there must be a fi to show where the if block ends.

Consider:

if grep moo file.txt |
      many more commands |
      in a complex pipeline |
      yielding a result which decides whether the "if" is true or not
then
    commands to execute if the outcome was true
    there could be many commands here too
    many many more, in fact
fi

unconditional commands ...