made main into a loop, now reads in multiple lines on input and outputs seperate files