syntax error near unexpected token `for file in

I am trying to run the code below however I am getting a "syntax error near unexpected token `for file in error" on the line that is in red. I have the semicolons after every line because it will fail on the copy if I don't have them saying that it cannot stat directory. Is there something that I am missing that would cause it to give me this error? I would really appreciate any advice or improvements.

#!/bin/bash -x

original=ALPHA.jan.R120110117.142731.txt; 

origcp=$original.original;

location=/home/testfiles/;

rec=1000001;

DT=20110117;

TM=120000;

prefix=ALPHA.jan;



cp $location$original $location$origcp;



wc -l $location$original;

wc -l $location$origcp;



split -l $rec -a 3 $location$original $location$original;

chmod 775 $location$original???

for file in $location$original???
 
do

wc -l $location$original???

break

done;





ini=161;

i=161;

for file in $location$original???;

do

output=$(printf '%X' $i)$DT.$TM.txt;

  mv $file $prefix.$output

  i=$((i + 1 + 7*($i-$ini==8)))

  ini=$((ini + 16*($i-$ini>8)))

  

  print $file has been renamed to $prefix.$output

   done;

I would suggest that the file is probably in DOS format (<CR> characters on the end of each line). Use dos2unix to fix it, and then get rid of the ; on the end of each line.

Also, you don't need a for loop to count the lines in the output files, so you can replace:

for file in $location$original???
do
    wc -l $location$original???
    break
done;

with: wc -l $location$original???

Use printf (or echo) not print:

printf "$file has been renamed to $prefix.$output"

If the script was edited with something like M$ Notepad it will be in MSDOS format. The usual problem is that the file is copied from a M$ platform to a unix server using binary mode ftp (not text mode ftp).

Also lose the semi-colons. This is not Oracle. There is never a reason to end a line in a semi-colon.

Hello,thanks to share with me but i'm beginner in programming so i can't help you.Thanks a lot again for sharing the information here...