Why does the following work in REPL
julia> A = rand(3,3)
3×3 Array{Float64,2}:
0.967353 0.187512 0.296005
0.616798 0.620456 0.076472
0.0759498 0.105753 0.41141
julia> writedlm("data2.txt", A)
julia>
But not in a script
A= rand(3,3)
file = open("data2.txt")
writedlm(file,A)
close(file)
I get the error:
ERROR: LoadError: ArgumentError: write failed, IOStream is not writeable
when I run the script in a terminal