use File.open instead of File.write