# Problem writing a text file

**URL:** <https://www.ruby-forum.com/t/problem-writing-a-text-file/163701>\
**Category:** Ruby\
**Created:** [March 24, 2009, 4:20am UTC](https://www.ruby-forum.com/t/problem-writing-a-text-file/163701 "2009-03-24T04:20:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [March 24, 2009, 4:20am UTC](https://www.ruby-forum.com/t/problem-writing-a-text-file/163701/1 "2009-03-24T04:20:42Z")

</div>

Hi,

I imported some test data from Excel as a CSV file.  
I massaged that data and tried to write it out as CSV text file.  
However, no file was created on the file system.

I’ve put out a snippet of the relevant code and debugging output at  
[http://www.pastie.org/425055](http://www.pastie.org/425055).

I’m running ruby 1.8.6 in WinXP-Pro/SP3.

Does anybody see any obvious (or subtle) error?

Thanks in Advance,  
Richard

---

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [March 24, 2009, 5:00am UTC](https://www.ruby-forum.com/t/problem-writing-a-text-file/163701/2 "2009-03-24T05:00:26Z")

</div>

On Mon, Mar 23, 2009 at 8:16 PM, RichardOnRails  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve put out a snippet of the relevant code and debugging output at  
> [http://www.pastie.org/425055](http://www.pastie.org/425055).

> Does anybody see any obvious (or subtle) error?

Quick glance: File.open(‘fn’, ‘w’) – you’re opening a file named ‘fn’,  
not the file with the name represented by the variable fn .

HTH,

---

<div class="post-metadata">

**Author:** ![RichardOnRails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e0b2c6/32.png) [@RichardOnRails](https://www.ruby-forum.com/u/RichardOnRails)\
**Post date:** [March 24, 2009, 6:25am UTC](https://www.ruby-forum.com/t/problem-writing-a-text-file/163701/3 "2009-03-24T06:25:43Z")

</div>

On Mar 23, 11:56 pm, Hassan S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## HTH,
> 
> Hassan S. ------------------------ removed\_email\_address@domain.invalid

Hi Hassan,

Once more, you’ve pulled my fat out of the fire. I apologize for  
bothering people on this newsgroup with my stupidity.

Thank you very much for you help.

Best wishes,  
Richard
