Thanks for your the update and this works for me and is there any other command I can use which is update directly inside the file rather than redirecting writing to other file.
There is a sed command with -i option.
But it is not always safe so you can use following in spite of that.
cat file.ksh
awk '{print NR, $0}' OFS=, Input_file > TEMP_FILE
if [[ -f TEMP_FILE ]]
then
mv TEMP_FILE Input_file
else
echo "Please check TEMP file has NOT been created."
fi
Here I am taking output to a temp file which I am later renaming as the Input_file by mv command. Hope this helps.