Fixed known error. Added some more error checking.

If a replacement flag is set and the arguments have been iterated
through, then the replacement wasn't provided. Hence, an error. Also,
if the inputfile wasn't provided we have an error.