Added output file functionality