while loop syntax error unexpected end of file
I have a syntax error with my while loop and my code is as follows

    #! /bin/bash
    # extracts pdb from mdcrd and fix number and move to one central location

    filename="min_8a-"
    i=1
    num_structures=1000
    natoms=97
    folders=15



    while [[ $i -le $folders ]]; do
     cd ~/new/sa/na-main/a-na-main/second/$i
     mkdir pdbfit

    x=1

     while [[ $x -le $num_structures ]]; do

       ptraj ./8a-${a}.prmtop << EOF
       trajin $filename$a.mdcrd $x $x 1
       trajout pdbfit/a-2-$i.pdb pdb dumpq
     EOF
     let x=$x+1
     done
 
     cd pdbfit 
     mv *.* ~/pdbfit
     cd ..
     rm pdbfit

    let i=$i+1
    done


I get line 34 syntax error stating " syntax error : unexpected end of file"


as a untrained eye I have tried but failed to fix this problem so if anyone can help me with this then that will be greatful. 
while loop syntax error unexpected end of file
===

I have a syntax error with my while loop and my code is as follows

    #! /bin/bash
    # extracts pdb from mdcrd and fix number and move to one central location

    filename="min_8a-"
    i=1
    num_structures=1000
    natoms=97
    folders=15



    while [[ $i -le $folders ]]; do
     cd ~/new/sa/na-main/a-na-main/second/$i
     mkdir pdbfit

    x=1

     while [[ $x -le $num_structures ]]; do

       ptraj ./8a-${a}.prmtop << EOF
       trajin $filename$a.mdcrd $x $x 1
       trajout pdbfit/a-2-$i.pdb pdb dumpq
     EOF
     let x=$x+1
     done
 
     cd pdbfit 
     mv *.* ~/pdbfit
     cd ..
     rm pdbfit

    let i=$i+1
    done


I get line 34 syntax error stating " syntax error : unexpected end of file"


as a untrained eye I have tried but failed to fix this problem so if anyone can help me with this then that will be greatful. 