diff --git a/prog/data_utils.py b/prog/data_utils.py
index d2e99b6a752d98b915dcd93303c6916fff739c36..ded0997e829894e76c23b6d07a0c387542c86f27 100644
--- a/prog/data_utils.py
+++ b/prog/data_utils.py
@@ -4,6 +4,7 @@ import math
 import pprint
 import time
 import datetime
+import pathlib
 
 import gtfs
 from utils import *
@@ -229,20 +230,19 @@ class TripPoint:
         self.openapi_next_stop = json['properties']['last_position']['next_stop']
         self.openapi_delay = json['properties']['last_position']['delay']
 
-def write_data(path, dt):
+def write_data(dt, data):
     import random
 
     def only_printable_acii(s):
         return all(ord(x) >= ord(' ') for x in s) and s.isascii()
 
-    tmp_file = dt.strftime(f"tmp/realtime-%Y-%m-%d--%H-%M-%S-{randint(random.randint(0,100000))}")
+    tmp_file = dt.strftime(f"tmp/realtime-%Y-%m-%d--%H-%M-%S-{random.randint(0,100000)}")
 
     if  type(data) == dict:
         os.mkdir(tmp_file)
-        pathlib.Path(path)
-        for fname, d in data:
+        for fname, d in data.items():
             assert '/' not in fname and only_printable_acii(fname)
-            with open(tmp_file+'/'+fname, "wb") as f:
+            with open(tmp_file+'/'+fname, "xb") as f:
                 f.write(d)
     else:
         with open(tmp_file, "xb") as f: