Critique: 1) no LICENSE file 2) not configurable 3) not idiomatic ruby (e.g. camelCase not snake_case) 4) overtly complicated. A better, and shorter version, is: bad_whitespace = " " ARGF.inplace_mode = "" ARGF.each_line do |line| print line.gsub(" ", bad_whitespace) end 5) bad commenting. The style of commenting each line for what it does is often silly. Something like "fileModified.close # Close file" tells me exac…
Out of curiosity (haven't done ruby for awhile): is your line-by-line implementation safe? Is it guaranteed that the lines are identical in the output file besides the character you're replacing? I'm thinking different CR+LR combinations. What if the final line is not terminated by newline? Doesn't print always add it?
'print' does not
The code does handle/preserve all the cases you mentioned (\r\n, final or no final terminating newline, etc).