Changed filename parser and 'File.open' to 'File.write'.