# Re: add to words syntaxes

**URL:** <https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82504>\
**Category:** Ruby\
**Created:** [March 16, 2006, 11:51am UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82504 "2006-03-16T11:51:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@dani](https://www.ruby-forum.com/u/dani)\
**Post date:** [March 16, 2006, 11:51am UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82504/1 "2006-03-16T11:51:33Z")

</div>

If I understand you well the script should look like this:

outfile = ARGV.shift

lines = ARGF.readlines

nyomtatvanyazonosito, nev, adoszam, adoazonosito, tol, ig =  
lines.slice!(0,6).map {|w| w.chomp.chomp(’;’) }  
first\_six\_data = \<\<-EOT  
‘\<?xml version="1.0" encoding="windows-1250"?\>’  
‘’

‘’#{nyomtatvanyazonosito}’’  
‘’  
‘’#{nev}’’  
‘’#{adoszam}’’  
‘’#{adoazonosito}’’  
‘’  
‘’  
‘’#{tol}’’  
‘’#{ig}’’  
‘’  
‘’  
‘’  
EOT

marked\_up\_lines = lines.map do |line|  
words = line.split  
‘’ + words[1] + ‘’ + “\n”  
end

File.open(outfile,‘w’) do |file|  
file.write marked\_up\_lines.join  
end

But if i run it so in the ouput only the things after the first six  
lines appear…

Daniel

---

<div class="post-metadata">

**Author:** ![dani](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@dani](https://www.ruby-forum.com/u/dani)\
**Post date:** [March 16, 2006, 12:28pm UTC](https://www.ruby-forum.com/t/re-add-to-words-syntaxes/82504/2 "2006-03-16T12:28:13Z")

</div>

Dani wrote:

> If I understand you well the script should look like this:
> 
> outfile = ARGV.shift
> 
> lines = ARGF.readlines
> 
> nyomtatvanyazonosito, nev, adoszam, adoazonosito, tol, ig =  
> lines.slice!(0,6).map {|w| w.chomp.chomp(‘;’) }  
> first\_six\_data = \<\<-EOT  
> ‘\<?xml version="1.0" encoding="windows-1250"?\>’

Why the quotes here? The string is everything between the line following  
“\<\<-EOT” and “EOT”. See  
[http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#here\_doc](http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#here_doc)

[…]

> File.open(outfile,‘w’) do |file|

# You forgot to write the variable first\_six\_data here.

```
 file.write first_six_data

```

> file.write marked\_up\_lines.join

# And here probably you need to write

```
 file.write "</...></...></...>"

```

> end

HTH
