# Rewriting a message into a new rosbag

I have a rosbag that publishes the paths of a robot only once. I am writing a plugin to visualize it, so I want to rewrite the message again and again into my new rosbag. Below is the code, I am not sure if it is right, because my new rosbag doesn't publish it in constant fashion.

import rosbag
import random

with rosbag.Bag('Plugin.bag', 'w') as outbag:

for topic, msg, t in rosbag.Bag('2016-07-18-16-06-32.bag').read_messages():
if topic == "/input/path_manager/path" and msg.header: