Better way to check if a document is saved

Previous way of checking was checking if the name of the file; but it
could exist a saved document whose name contains the word “Untitled”