diff --git a/runtime/vtk.hpp b/runtime/vtk.hpp
index 349b66c01e1bc8ee199452bece8e703c8894ec74..3ae69e15b349fa28ac4d94fdc77b65d75d013d77 100644
--- a/runtime/vtk.hpp
+++ b/runtime/vtk.hpp
@@ -12,8 +12,9 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
     std::string output_filename(filename);
     auto masses = ps->getAsFloatProperty(ps->getPropertyByName("mass"));
     auto positions = ps->getAsVectorProperty(ps->getPropertyByName("position"));
-    const int n = end - start;
+    auto flags = ps->getAsIntegerProperty(ps->getPropertyByName("flags"));
     const int prec = 8;
+    int n = end - start;
     std::ostringstream filename_oss;
 
     if(frequency != 0 && timestep % frequency != 0) {
@@ -31,6 +32,12 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
     ps->copyPropertyToHost(masses);
     ps->copyPropertyToHost(positions);
 
+    for(int i = start; i < end; i++) {
+        if(!(flags(i) & FLAGS_INFINITE)) {
+            n--;
+        }
+    }
+
     if(out_file.is_open()) {
         out_file << "# vtk DataFile Version 2.0\n";
         out_file << "Particle data\n";
@@ -39,21 +46,27 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
         out_file << "POINTS " << n << " double\n";
 
         for(int i = start; i < end; i++) {
-            out_file << std::fixed << std::setprecision(prec) << positions(i, 0) << " ";
-            out_file << std::fixed << std::setprecision(prec) << positions(i, 1) << " ";
-            out_file << std::fixed << std::setprecision(prec) << positions(i, 2) << "\n";
+            if(!(flags(i) & FLAGS_INFINITE)) {
+                out_file << std::fixed << std::setprecision(prec) << positions(i, 0) << " ";
+                out_file << std::fixed << std::setprecision(prec) << positions(i, 1) << " ";
+                out_file << std::fixed << std::setprecision(prec) << positions(i, 2) << "\n";
+            }
         }
 
         out_file << "\n\n";
         out_file << "CELLS " << n << " " << (n * 2) << "\n";
         for(int i = start; i < end; i++) {
-            out_file << "1 " << (i - start) << "\n";
+            if(!(flags(i) & FLAGS_INFINITE)) {
+                out_file << "1 " << (i - start) << "\n";
+            }
         }
 
         out_file << "\n\n";
         out_file << "CELL_TYPES " << n << "\n";
         for(int i = start; i < end; i++) {
-            out_file << "1\n";
+            if(!(flags(i) & FLAGS_INFINITE)) {
+                out_file << "1\n";
+            }
         }
 
         out_file << "\n\n";
@@ -61,7 +74,9 @@ void vtk_write_data(PairsSimulation *ps, const char *filename, int start, int en
         out_file << "SCALARS mass double\n";
         out_file << "LOOKUP_TABLE default\n";
         for(int i = start; i < end; i++) {
-            out_file << std::fixed << std::setprecision(prec) << masses(i) << "\n";
+            if(!(flags(i) & FLAGS_INFINITE)) {
+                out_file << std::fixed << std::setprecision(prec) << masses(i) << "\n";
+            }
         }
 
         out_file << "\n\n";