How to set PageWidth when using PutAppend to append expressions to a file?

Do[
PutAppend[Table[i, {RandomInteger[100]}], "./file.m"],
{i, 100}
]


I'd like each inner list to always appear on the same line, but not automatically wrapped at 68th character. How to achieve that? I wonder where and how the PageWidth option should be set for the InputStream used by the PutAppend.

#!/usr/bin/env bash

sed -e '
/.* $/ { N /\n .*$/ {
s/$$.*$$ \n $$.*$$/\1 \2/
}
}
' \$1


will fix the broken lines.

-

I believe you should use streams:

stream = OpenWrite["wraptest.m", PageWidth -> Infinity];

Do[PutAppend[Table[i, {RandomInteger[100]}], stream], {i, 100}]


You can also use Write in place of PutAppend:

 Do[stream ~Write~ Table[i, {RandomInteger[100]}], {i, 100}]


Be sure to Close your stream when you are done:

Close[stream];

-
It's well acceptable. The documentation doesn't say the second argument can be a stream expression. –  qazwsx Apr 24 '12 at 4:26
If I have a file written in my original way and have some long lines wrapped, how to amend it so each line has exactly one expression (List in this case) without rewriting the large file? –  qazwsx Apr 24 '12 at 4:27
@Problemania I didn't check the documentation before posting; I thought it was in there but it seems not. As for fixing your existing file my first inclination is to read in the data and write it to a new file. If memory usage is your concern you can do it line by line with Read and Write. –  Mr.Wizard Apr 24 '12 at 4:33
Writing those files took hours. To fix the line breaks, I would have to basically rewrite them? It doesn't have to use Mathematica if there is better way to do it. It seems the broken long line always has the second and additional lines start with white spaces. Maybe that could be exploited? –  qazwsx Apr 24 '12 at 4:44
I find a way to fix the long lines with sed (see in OP). –  qazwsx Apr 24 '12 at 5:45