I recently spent a few agonizing hours struggling to get a ruby script to work.
The script was iterating over standard input and subjecting the input line to a file/dir test. Valid files were not being recognized.
I later realized that the cause of the problem was the newline that is included in the input received from standard input. After stripping away the newline, the script worked.