This isn't possible without a framework like ncurses which keeps track of the state of the entire screen. Terminals are write-only by default. See e.g. this question.