The file_name
contains the newline character \n
at the end, which won’t get printed but messes up the path. You can fix the issue by stripping the line
first:
initial, final, file_name = line.strip.split("\t")
When debugging code, be careful with puts
. Quoting its documentation reveals an ugly truth:
Writes the given object(s) to ios. Writes a newline after any that do not already end with a newline sequence.
Another way to put this is to say it ignores (potential) newlines at the end of the object(s). Which is why you never saw that the file name actually was SVNFolders.txt\n
.
Instead of using puts
, you can use p
when troubleshooting issues. The very short comparison between the two is that puts
calls to_s
and adds a newline, while p
calls inspect
on the object. Here is a bit more details about the differences: http://www.garethrees.co.uk/2013/05/04/p-vs-puts-vs-print-in-ruby/