should beCode:while(tok='\n')Also, you never opened an output file, and even if you had, you aren't ever actually outputting the token, you are only outputting the '$'. Your output file would just be:Code:while(tok=='\n')
$$$$$$$$$$$$$$$$$$$$$$$$
Try fixing those problems first and then see if you can figure out the rest.