Changed all the dollar sign to EOF and updated the code in the function