Fix issue opening file name ending with "~"

The 'helm-substitute-in-filename' function strips part of the open file
path before "~", so that paths such as "/abc~user/d" will be come
"~user/d". Unfortunately, the function also changes file name such as
"temp_file~" to just "~", making it impossible to open files ending in
"~".