how can I add a horizental line above my page and write above it. like that

• You are looking for a feature called "headers". You can search this site. See also the fancyhdr package. Welcome to the site. Jun 12 at 23:41
• See here for example: overleaf.com/learn/latex/Headers_and_footers Jun 13 at 1:37

Here's an example that is based on here. The manual for the package fancyhdr can be found here.

% Based on https://overleaf.com/learn/latex/Headers_and_footers

\documentclass{book}

\usepackage{blindtext}
\usepackage{fancyhdr} % <-- Important package!

\pagestyle{fancy}
\fancyhf{} % Clear all header and footer fields and then re-define the field, see below.
\fancyfoot[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}

% E for even page
% O for odd page
% L for left side
% C for centered
% R for right side