Use a password manager Eg. KeyPass. Use F-droid instead of appstore when I can. Use DNS encryption always and use the tor network when browsing the internet. Use open source software that you trust. And if you really value your privacy use Linux.
Allso disconnect social media from your real life. Use a burner email to sign up to sketchy services. Don’t forget to log out of you account when on a school/work/unknown device.
More generally be interested in cyber security and you will become safer.
Im pretty sure its because of char 13 (carriage return). This char sets cursor to the start of the line overwriting whatever was printed there (in most terminals). I belive that some error messages use this char and when you print something the char at the begining or end of the error message overwrites your message. A workaround is simply printing a newline after or before your message.