Changed outfile to a pointer.
Fixed the enormous error by having outfile as a pointer instead and giving filename as a char array. Kudos to jaremikb