Audio loadstream - interesting problem

Hello,
I have a problem loading sounds by audio.loadStream when I get the file names by reading the file names from a text document.
If I define the audio file names in a string array, I can load the sounds without problem, but when I read them from file, I dont get an error but the sounds dont play.
for eg:
if I do as below, it works without a problem:

soundFNameStrings[1] = "abc1.ogg" soundFNameStrings[2] = "abc2.ogg" ...

but if I do as below, the sounds doesnt play:

path = system.pathForFile( "filenames.txt", system.ResourceDirectory)  
fh = io.open( path )  
fileCount = 1  
for line in fh:lines() do  
 soundFNameStrings[fileCount] = tostring(line)  
 fileCount = fileCount + 1  
end  

We can think, I have a problem getting filenames, but I checked it also. Just before loading the sounds, I displayed all the soundFNameStrings on the screen for both cases, They are fully same. But first is working, second is not.
What can be the problem?

Thanks. [import]uid: 183134 topic_id: 34811 reply_id: 334811[/import]

Most likely there is a newline character (\n or CTRL-L) at the end of your file name since you’re reading it in from a file and there are line separators.

What you need is a “trim” function. I use this:

function string:trim()  
 return (self:gsub("^%s\*(.-)%s\*$", "%1"))  
end  

then

soundFNameStrings[fileCount] = tostring( line:trim() )  

[import]uid: 199310 topic_id: 34811 reply_id: 138404[/import]

Yes, that’s right. Thank you very much. [import]uid: 183134 topic_id: 34811 reply_id: 138447[/import]

Most likely there is a newline character (\n or CTRL-L) at the end of your file name since you’re reading it in from a file and there are line separators.

What you need is a “trim” function. I use this:

function string:trim()  
 return (self:gsub("^%s\*(.-)%s\*$", "%1"))  
end  

then

soundFNameStrings[fileCount] = tostring( line:trim() )  

[import]uid: 199310 topic_id: 34811 reply_id: 138404[/import]

Yes, that’s right. Thank you very much. [import]uid: 183134 topic_id: 34811 reply_id: 138447[/import]