# Re: file\_put\_contents analog?

**URL:** <https://www.ruby-forum.com/t/re-file-put-contents-analog/72065>\
**Category:** Ruby\
**Created:** [October 13, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/re-file-put-contents-analog/72065 "2006-10-13T22:41:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 13, 2006, 10:41pm UTC](https://www.ruby-forum.com/t/re-file-put-contents-analog/72065/1 "2006-10-13T22:41:52Z")

</div>

From: Gavin K.

> ```
> contents.each{ |item|
> file << item
> }
> 
> ```
> 
> }  
> end

Er, missing a paren there. Also, if you want append vs. wipe-and-write,  
use ‘a’:  
def file\_put\_contents( name, \*contents )  
File.open( name, “a” ){ |file|  
contents.each{ |item|  
file \<\< item  
}  
}  
end
