filename = '~/file.txt' f = File.open(filename, 'w') f.puts("hello world") f.close