Made script more robust by adding option for input file