used f.puts instead of f.writes