Changed order of outout and made it possible to specify an output file instead of just std.out
Added possibility for easy testing