I get an unwanted '?' at the end of my file name while doing this: 

```
emplid=$(grep -a "Student ID" "$i".txt  | sed 's/(Student ID:  //g' | sed 's/)Tj//g' ) 
 #gets emplid by doing a grep from some text file
echo "$emplid"   #prints employee id correctly 
cp "$i" "$emplid".pdf  #getting an extra '?' character after emplid and before .pdf

```

i.e instead of getting the file name like 123456.pdf , I get 123456?.pdf . 
Why is this happening if the echo prints correctly? 
How can I remove trailing question mark characters ?