It works for saved and unsaved files. Maybe unsaved file's content should be written to a temporary file in case we crash, so that the user doesn't lose all it's content.