$ curl cheat.sh/
#=
 = By iteratively do you mean another application/program must be able to
 = read the file in between writes? Otherwise you can just open the
 = stream once then close at the end.
 =#

 f = open(outfile,"w") # do this once
 for i in someloop
     # do something
     write(f, "whatever") # write to stream but not flushed to disk
 end
 close(f) # now everything is flushed to the disk (i.e. now outfile will have changed)

#=
 = If you need to access the file during the process then you can
 = open/close during every iteration (maybe write is faster than println,
 = profile it to check) or you could just open/close the stream every N
 = iterations to balance the two?
 = 
 = **Edit**:
 = Source:
 = http://docs.julialang.org/en/release-0.4/manual/networking-and-
 = streams/
 = 
 = Like @isebarn said writing binary to hdf5 may also be faster. Not sure
 = though.
 = 
 = Also also IO is quite often a limiting factor in these sorts of
 = scenarios. The other thing to try is if there is a way to estimate P
 = you could pre-allocate and then trim it?
 = 
 = [Alexander Morley] [so/q/39249754] [cc by-sa 3.0]
 =#

$
Follow @igor_chubin cheat.sh