Shell program error!!!

Hello guys,
This is an executable shell program that I want to execute, but it doesn't execute and gives error. The shell program that I want to execute is taken from a well-reputed book on Solaris 10.
Here is the program

 
#!/usr/bin/bash
if test -a $1 then
echo "Number of lines in file " $1
wc -l $1
else
        echo "The file" $1 "does not exist"
fi
 

And here is the error

-bash-3.00$ ./test.sh /etc/passwd
./test.sh: line 5: syntax error near unexpected token `else'
./test.sh: line 5: `else'

Could you please figure out what causes the error.
And what is the function of $1 in these shell programs. Please pardon me as I am new to unix shell programming.

You need a newline before then , i.e.

if test -a $1
then
   echo ...

$1 is the value of the first argument.

Info : -a is not available in sh shell ..

alternate code ..

$ [ -e "$1" ] && echo "Line cnt : $(wc -l < $1)" || echo "File not exists"