Now accepts output file as second parameter