file, directory, or volume name is incorrect

I'm running into a problem when I'm sure that I'm passing the Open function a correct path name, so I must be missing something somewhere!

Here's a simplified version of the code:
Function openFiles()
    Variable refNum
    Open /D /R /MULT=1 /M="Select one or more files" refNum
    String outputPaths
    outputPaths = S_fileName   
    print outputPaths // prints C:Users:Kevin:Documents:igor coding:dataset1.txt
   
    Open /R refNum as outputPaths
End


When I run that, I get: "While executing Open, the following error occurred: The file, directory, or volume name is incorrect."

However, when I replace
Open /R refNum as outputPaths

with
Open /R refNum as "C:Users:Kevin:Documents:igor coding:dataset1.txt"

then everything works fine. This confuses me, because outputPaths is a string, and is the exact same string that I hard coded in the second example there. Why isn't this working when I put the string variable in there? I'm sure it's obvious, but I can't seem to figure that out right now! Thanks very much for the help.

Kevin
Open /MULT=1 returns a carriage-return (CR) delimited list of full paths. This means there will be a CR after each path. So you are passing a path that ends with a CR to the Open/R operation.

If you are dealing with just one file, remove the /MULT=1.

If you need to handle multiple files then you need to extract them from the CR-delimited list using StringFromList with CR ("\r") as the listSepStr parameter.
Ah, thank you so much! I do need to open multiple files, but I was just testing a basic version of the function with 1 file, so it would have taken me forever to realize that was the issue! Thanks again.

Kevin