When bidding farewell to someone at the end of the evening, you have the option to use either goodnight or good night. Nevertheless, in formal writing, it is deemed more appropriate to spell it as good night with two distinct words.