Ask coding questions

← Back to all posts
writing to files help
demacedone (1)

I have a problem, I'm trying to write things to a file. The things I'm writing to a file need to be put into a loop, and I only want there to be 14 iterations of the loop. And the loop goes through 14 times just fine. But for whatever reason, it doesn't write to the file.
However, if I put no bounds on the loop (making it go forever) it writes just fine. Same goes for a large amount of iterations.

Can I get some suggestions?

Commentshotnewtop
ash15khng (650)

It works just fine for me?

gdampix (0)

where was the problem.. it might help me
@demacedone

demacedone (1)

@gdampix all I had to do was close the file. We didn’t discuss it in class.

gdampix (0)

@demacedone u wrot
"However, if I put no bounds on the loop (making it go forever) it writes just fine. Same goes for a large amount of iterations."
how come? if u didnt closed file earlier.

demacedone (1)

@gdampix close the file after all the iterations