Fix index bug
Loop length
Create CSV file
Clean even when interrupted