Well, hardly a MWE… please do read the link I sent. But try something like
julia> io = open("myfile.txt", "a");
julia> write(io, "Hello world!");
julia> close(io);
(from the doc-string) Note the io. In your example you open a file with open and then open another one with write.