Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7172717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:40:23+00:00 2026-05-28T15:40:23+00:00

I am using ColdFusion 8. I am trying to write this code block in

  • 0

I am using ColdFusion 8.

I am trying to write this code block in CFSCRIPT, but can’t quite get it.

<cfloop query="Q">
    <cfscript>
        // CREATE NEW LINE
        NewLine = "";
    NewLine = NewLine & Q.product_url;
    </cfscript>
    <cffile action="append" file="#ThisFile#" output="#NewLine#">
</cfloop>

Here is the CFSCRIPT

// LOOP THROUGH QUERY RESULTS
for (i = 1; i lte Q.RecordCount; i=i+1) {
    // CREATE NEW LINE
    NewLine = "";
    NewLine = NewLine & Q.product_url[i];
    // READ THE FILE
    File = fileOpen(ThisFile, "read");
    // WRITE NEW LINE TO FILE
    fileWriteLine(File, "#NewLine#");
    fileWrite(ThisFile, File);
    fileClose(File);
}

I know I am supposed to open the file, modify it, then close the file. I think I need to do that with each new line added.

What’s wrong with this code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:40:24+00:00Added an answer on May 28, 2026 at 3:40 pm

    Fixed:

    <cfscript>
        myFile = fileOpen(ThisFile, "append");
    
        for (i = 1; i lte Q.RecordCount; i=i+1) {
            NewLine = "";
            NewLine = NewLine & Q.product_url[i];
    
            fileWriteLine(myFile, "#NewLine#");
        }
    
        fileClose(myFile);
    </cfscript>
    

    Issues addressed:

    1. You don’t open and close the file each line; you a) open file, b) write 1-x lines, then c) close the file (alternately, you can write it all at once with fileWrite() )

    2. You don’t need both fileWriteLine and fileWrite, fileWriteLine is for line-by-line writing, while fileWrite is for writing and entire set of data in one shot.

    I also changed the “write” to “append”, in case the file you’re writing to doesn’t exist upon the first execution–obviously, if you can guarantee your destination file exists, you can replace “append” with “write”. Keep in mind that changing this will also grow your file over time; it may not be what you want, so switch it back to “write” if this is the case.

    Although I can’t be certain without seeing your exact error, I have a hunch it was FileWrite() line that was the culprit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create pagination for search results using MySQL and ColdFusion. My intention
How can dynamic HTML be put into a PDF using ColdFusion? This is in
I'm trying to use a Java object in Coldfusion using the CreateObject function. This
I'm trying to obtain credentials from ning network using Coldfusion 9, so first this
Overnight hack, trying to create an environment where GAE code (using Python libs/packages) could
I'm using coldfusion 9 and I'm trying to grab a file from an ftp
I want to make an FTP connection (ideally using Coldfusion 8, but Java is
Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single
I'm using coldfusion and jquery. This is my first real go at jquery and
I am using ColdFusion 9.0.1. I am trying to test whether a user has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.