Printf problem

I am having a major problem with printf, The more I pad it, the less I see :frowning:

The problem is in the first function, report
Am I ruining output somewhere? I wont print out the names propely, it cuts them off or deletes them completely :frowning:

#!/bin/bash

report()
{
    printf "%-10s" STUD# 
    printf "%-20s" Name 
    printf "%-10s" A1  A2  A3  A4  A5  EXE  TUT  EXAM  TOTAL
    echo
    echo "----------------------------------------------------------------------------------------------------------"

    IFS2=$IFS
    exec 0<"$FILE"

    IFS=":"

    while read STUDNO USRNM A1 A2 A3 A4 A5 e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 TUT EXAM
    do
        IFS=$IFS2
        NAME=`searchPasswd "$USRNM"`
        IFS=":"

        printf "%-10s" $STUDNO 
        printf "%-20s" $NAME
        #printf "%-10s" $A1 $A2 $A3 $A4 $A5 $e1 $TUT $EXAM
        echo
        
    done
    IFS=$IFS2

    
}

searchPasswd()
{    
    A=`sed -n "/$1/p" /etc/passwd` 
        newName=`echo "$A" | cut -f 5 -d ":"` 
        newName=`echo "$newName" | cut -f 1 -d ","` 
        echo $newName
}

#Set arguments
if [ ! -z "$1" ] && [ ! -z "$2" ]
then
    report=$1
    FILE=$2
    
    #Check file is good
    if [ ! -f $FILE ]; then
          echo "$FILE : does not exists"
          exit 1
       elif [ ! -r $FILE ]; then
          echo "$FILE: can not read"
          exit 2    
       fi

    echo "Report type is ------->" $report 
    echo "Filename is ---------->" $FILE

    report $FILE
else
    echo "fail"
fi


If you use sed, grep, ... to search with "field" value, then search have to include delimiters

A=`sed -n "/^$1:/p" /etc/passwd`

Why use exec, why not pipe ?

cat "$FILE" | while

Or redirect

while ...
do
   ...
done < "$FILE"

This is an assignment to get some understanding of shell scripting.
I'm using sed because thats what i'm supposed to use.

The code gets the name, If I output just the name it works. Also If I output everything except the name I get it also works. Its only when I try out put it all... so I think it might be the get name function

Sed is a good tool and does it quite simply considering whats in the file