Solving memory issue and adding option to specify as argument the input filename