Added output file specification

And corresponding file checks. Should probably add some permission
checks as well but meh.