Python beginner file

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

Cannot understand why does not the file open?

can you please make add mode like how your file need to open ,
like

f= open(“guru.txt”,“w+”)

it might fix your problem