def stringReplace(searchString, replaceString, fileName) aFile = File.open(fileName, "r") aString = aFile.read aFile.close aString.gsub!(searchString, replaceString) File.open(fileName, "w") { |file| file << aString } end stringReplace(*ARGV)