You need zip-function, which is available in most languages. It's purpose is parallel processing of two or more arrays.
In Ruby it will be something like this:
f1 = File.readlines('file1.txt')
f2 = File.readlines('file2.txt')
File.open('file3.txt','w') do |output_file|
f1.zip(f2) do |a,b|
output_file.puts a.sub('/article/','/article/'+b)
end
end
For zipping more, than two arrays you can do f1.zip(f2,f3,...) do |a,b,c,...|