I would like to insert lines into a file in bash starting from a specific line.

Each line is a string which is an element of an array

line[0]="foo"
line[1]="bar"
...

and the specific line is 'fields'

file="$(cat $myfile)"
for p in $file; do
    if [ "$p" = 'fields' ]
        then insertlines()     #<- here
    fi
done
Edit
Report