Looks like i have a \r character in the input file. Hence the moment i print the API_NAME, the rest of the line gets printed in the next line. When the loop goes through the next iteration, the previously printed line gets over written.
To solve this, i have remove the "\r" char in the API_NAME.
tr -d '\r'