Updating a .txt file I'm outputting the results of a query to file.txt in JSON. The file is updated every time I click on 'submit'(form) and depending on the variables it updates the query.

Right now the table only has about 20 records and will probably increase by 2/3 new records everyday.

Is there a better way to updating the file test.txt getting the results from a query?

index.cfm:

  &lt;cfsavecontent variable="mytest"&gt; 
    [
    &lt;cfoutput query="getimeline"&gt; 
    &lt;cfif (getimeline.CurrentRow EQ getimeline.RecordCount)&gt;
    {"title":"#name_time#","date":"#dateformat(date_time,"mmmm d, yyyy")#"}
    &lt;cfelse&gt;
    {"title":"#name_time#","date":"#dateformat(date_time,"mmmm d, yyyy")#"},
    &lt;/cfif&gt;

    &lt;/cfoutput&gt; 
    ]
    &lt;/cfsavecontent&gt; 

    &lt;cffile action="write" file="C:test.txt"  output="#mytest#"&gt; 


test.txt:

[

{"title":"Advance pay Rollovers","date":"October 23, 2015"},

{"title":"New Card Ordering Process 1","date":"December 28, 2015"},

{"title":"about about","date":"February 5, 2016"}

]
I don't know sqat about coldfusion, but it seems you could eliminate some duplication:

&lt;cfsavecontent variable="mytest"&gt; 
    [
    &lt;cfoutput query="getimeline"&gt; 
    {"title":"#name_time#","date":"#dateformat(date_time,"mmmm d, yyyy")#"}&lt;cfif (getimeline.CurrentRow NEQ getimeline.RecordCount)&gt;,&lt;/cfif&gt;    
    &lt;/cfoutput&gt; 
    ]
&lt;/cfsavecontent&gt; 

&lt;cffile action="write" file="C:test.txt"  output="#mytest#"&gt; 


If you don't mind that the comma will get placed on the next line,
then you can use this more readable writing style:

&lt;cfsavecontent variable="mytest"&gt; 
    [
    &lt;cfoutput query="getimeline"&gt; 
    {"title":"#name_time#","date":"#dateformat(date_time,"mmmm d, yyyy")#"}
    &lt;cfif (getimeline.CurrentRow NEQ getimeline.RecordCount)&gt;,&lt;/cfif&gt;    
    &lt;/cfoutput&gt; 
    ]
&lt;/cfsavecontent&gt; 

&lt;cffile action="write" file="C:test.txt"  output="#mytest#"&gt;