diff --git a/src/FileDmaInputFilter.cc b/src/FileDmaInputFilter.cc
index cb94aa01fb3a7a788e2a2528eb96c4534bedc1cf..f199a14a108d3e9ceff3e8726ad1864b063707b0 100644
--- a/src/FileDmaInputFilter.cc
+++ b/src/FileDmaInputFilter.cc
@@ -6,6 +6,7 @@
 
 #include <cassert>
 #include <cerrno>
+#include <cstdint>
 #include <sstream>
 #include <system_error>
 
@@ -19,6 +20,9 @@ FileDmaInputFilter::FileDmaInputFilter(const std::string &filename, size_t packe
     throw std::invalid_argument("Invalid input file name: " + filename);
   }
   LOG(TRACE) << "Created file input filter";
+  fseek(inputFile, 0, SEEK_END);  // seek to end of file
+  file_size = ftell(inputFile);   // get current file pointer
+  fseek(inputFile, 0, SEEK_SET);  // seek back to beginning of file
 }
 
 FileDmaInputFilter::~FileDmaInputFilter() {
@@ -32,25 +36,31 @@ FileDmaInputFilter::~FileDmaInputFilter() {
  *
  * TODO: Better would be mmap directly the file
  */
-static inline ssize_t read_dma_packet_from_file(FILE *inputFile, char *buffer, ssize_t size,
-                                                uint64_t nbReads) {
+ssize_t FileDmaInputFilter::read_dma_packet_from_file(FILE *input_file, char *buffer, ssize_t size,
+                                                      uint64_t nbReads) {
   static constexpr uint64_t deadbeef = 0xdeadbeefdeadbeefL;
   ssize_t bytesRead = 0;
   size_t rc;
 
-  while (!feof(inputFile) && bytesRead < size) {
+  while (!feof(input_file) && bytesRead < size) {
     // Expecting 32 byte alignment
-    rc = fread(buffer, 1, 32, inputFile);
+    rc = fread(buffer, 1, 32, input_file);
 
-    if (ferror(inputFile)) {
+    if (ferror(input_file)) {
       throw std::system_error(errno, std::system_category(), "File error");
     }
 
     if (rc != 32) {
-      if (feof(inputFile) && rc == 0 && bytesRead == 0) {
-        // We have reached the perfect end of the file, let's start again
-        fseek(inputFile, 0, SEEK_SET);
-        continue;
+      if (feof(input_file) && rc == 0 && bytesRead == 0) {
+        stats.num_bytes += file_size;
+        if ((stats.num_bytes / file_size) != 100) {
+          // We have reached the perfect end of the file, let's start again
+          fseek(inputFile, 0, SEEK_SET);  // seek back to beginning of file
+          continue;
+        } else {
+          // We stop at 100 * file size
+          return 0;
+        }
       }
 
       // Misaligned data
@@ -74,7 +84,7 @@ static inline ssize_t read_dma_packet_from_file(FILE *inputFile, char *buffer, s
   //   or the packet cannot fit into the buffer
   // We can deal with both conditions but for the moment we throw an error
 
-  if (feof(inputFile)) {
+  if (feof(input_file)) {
     throw std::runtime_error("EOF reached but no end of the packet found.");
   }
 
diff --git a/src/FileDmaInputFilter.h b/src/FileDmaInputFilter.h
index 20c7df1afd46cf8d458b3ab1421f516d0ab0f52c..9ea947f5553ac69ac781746b43a89caae2d72a8f 100644
--- a/src/FileDmaInputFilter.h
+++ b/src/FileDmaInputFilter.h
@@ -15,6 +15,8 @@ class FileDmaInputFilter : public InputFilter {
                      ctrl &control);
   ~FileDmaInputFilter() override;
 
+  ssize_t read_dma_packet_from_file(FILE *input_file, char *buffer, ssize_t size, uint64_t nbReads);
+
  protected:
   ssize_t readInput(char **buffer, size_t bufferSize) override;
   void print(std::ostream &out) const override;
@@ -24,9 +26,11 @@ class FileDmaInputFilter : public InputFilter {
 
  private:
   FILE *inputFile;
+  size_t file_size{};
 
   struct Statistics {
     uint64_t nbOversizedPackets = 0;
+    uint64_t num_bytes = 0;
   } stats;
 };