<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'Open a text file and re-write its contents into a new text file'</title>
    <description>Snipplr comments feed</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Fri, 17 Apr 2026 02:53:04 +0000</lastBuildDate>
    <item>
      <title>c00lryguy said on 13/Jun/2008</title>
      <link>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</link>
      <description>&lt;p&gt;&lt;p&gt;dude.. why not:&lt;/p&gt;

&lt;p&gt;File.open("./lol.txt", "r") { |file| File.new("./#{ File.basename(file.path, ".txt") }_new.txt", "w+").puts(file.read) }&lt;/p&gt;

&lt;p&gt;Or:&lt;/p&gt;

&lt;p&gt;File.open("./lol.txt", "r") { |file&lt;em&gt;old| 
    file&lt;/em&gt;new&lt;em&gt;filename = "#{ File.basename(file.path, ".txt") }&lt;/em&gt;new.txt" #append "&lt;em&gt;new" to the end of the filename
    file&lt;/em&gt;new = File.new(file&lt;em&gt;new&lt;/em&gt;filename, "w+")
    file_new.puts(file.read) 
  }&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jun 2008 18:14:56 UTC</pubDate>
      <guid>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</guid>
    </item>
    <item>
      <title>c00lryguy said on 13/Jun/2008</title>
      <link>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</link>
      <description>&lt;p&gt;&lt;p&gt;Gah, the site messed up the second one. but you get the point. Ruby is stronger than you think&lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 13 Jun 2008 18:15:48 UTC</pubDate>
      <guid>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</guid>
    </item>
    <item>
      <title>chrisaiv said on 20/Jun/2008</title>
      <link>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</link>
      <description>&lt;p&gt;&lt;p&gt;Right on "c00lryguy", thanks for the post.  You're right too, Ruby is one bad ass language. &lt;/p&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 20 Jun 2008 20:08:25 UTC</pubDate>
      <guid>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</guid>
    </item>
    <item>
      <title>hellen12 said on 14/Jan/2023</title>
      <link>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</link>
      <description>&lt;p&gt;Njmcdirect is an online service that allows New Jersey drivers to pay their parking, traffic, and red light camera tickets quickly and easily. With &lt;a href="https://www.chocolatechip-ui.com/pay-nj-tickets-online-njmcdirect.html"&gt;njmcdirect&lt;/a&gt;, drivers can pay for their tickets online, by phone, or by mail. Njmcdirect also provides important information on ticket deadlines, court information, appeals, and more.&lt;/p&gt;</description>
      <pubDate>Sat, 14 Jan 2023 17:10:48 UTC</pubDate>
      <guid>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</guid>
    </item>
    <item>
      <title>hennery00 said on 09/Mar/2023</title>
      <link>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</link>
      <description>&lt;p&gt;Determine the type of sewing machine you need. If you’re just getting started, you may want to start with a basic model that includes basic functions like stitching and hemming. If you’re more experienced, you may want to consider a &lt;a href="https://teamsewing.com/"&gt;Sewing&lt;/a&gt; machine with more advanced capabilities or one that can handle more intricate projects.&lt;/p&gt;</description>
      <pubDate>Thu, 09 Mar 2023 05:04:47 UTC</pubDate>
      <guid>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</guid>
    </item>
    <item>
      <title>joe412 said on 25/Jul/2023</title>
      <link>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</link>
      <description>&lt;p&gt;hello there&lt;/p&gt;</description>
      <pubDate>Tue, 25 Jul 2023 22:03:38 UTC</pubDate>
      <guid>https://snipplr.com/view/6583/open-a-text-file-and-rewrite-its-contents-into-a-new-text-file</guid>
    </item>
  </channel>
</rss>
