LRU.sh: line 121: syntax error near unexpected token `fi' : When ever i run the bash script i encountered this problem.
./LRU.sh: line 121: syntax error near unexpected token `fi'  i have no idea why. Kindly need your help.Below is my code.

    #!/bin/bash

    declare -i numOfPageRRef=0
    declare -i numOfFrames=$1
    declare -i a=0
    declare -i k=0
    declare -i c=0
    declare -i q
    declare -i c1=0



    OIFS=$IFS
    IFS=','
    read line < Input2.csv

    for val in $line
    do
    pageRef[$numOfPageRRef]=$val

    ((numOfPageRRef++))
    done
    #echo ${pageRef[@]}

    q[$k]=${pageRef[$k]}  #chck here
    echo ${q[$k]}
    ((c++))
    ((k++))

 
    for((i=1;i<numOfPageRRef;i++))
    do


    c1=0
    for((j=0;j<numOfFrames;j++))
    do


    if (( ${pageRef[$i]} -ne ${q[$j]} ))
    then
    ((c1++))
    fi
    done

    if (( c1 -eq numOfFrames ))
    then

    ((c++))

    if (( k -lt numOfFrames )) ;then

    q[$k]=${pageRef[$i]}
    ((k++))

    for((j=0;j<numOfFrames;j++))
    do
    echo ${q[$j]}
    done

    else 
    for((r=0;r<numOfFrames;r++))
    do

    c2[r]=0
    for((j=i-1;j<numOfPageRRef;j--))
    do

    if (( ${q[$r]} -ne ${p[$j]} ))   
    then
    ((c2[r]++))
    else break
    fi

    done
    done

    for((r=0;r<numOfFrames;r++))
    do
    t4=${c2[r]}
    b[$r]=$t4

    for((r=0;r<numOfFrames;r++)) 
    do

    for((j=r;j<numOfFrames;j++))
    do

    if (( ${b[$r} -lt ${b[$j]} ))
    then

    t=${b[r]}
    t2=${b[j]}
    b[$r]=$t2
    b[$j]=$t

    fi   
    done
    done

    for((r=0;r<numOfFrames;r++))
    do

    if (( ${c2[$r]} -eq ${b[0]} ))
    then

    t3=${p[$i]}
    q[$r]=$t3

    fi
    echo ${q[$r]}

    done

    #echo 

    fi
    fi
    done

    echo "The no of page fault is $c"



kindly need you help to rectified the problem.












