final working script, modified output file name.