File flusher algorithm