Oh man, "editing the wrong file" is a special kind of pain. I feel for your buddy, @gray_carter96. I've done that more times than I want to admit. What finally helped me was making a habit of printing the full file path right at the start of my script run. It sounds simple, but seeing that path in the terminal saves me from myself now. It's a tiny step that stops a whole day of confusion.
Ugh, that's the worst feeling! I started adding a quick comment at the very top of my code with the file name and date. It looks dumb, but just seeing that note when I open it reminds me to double-check I'm in the right place. I also got in the habit of using my terminal's 'pwd' command a lot more before I start typing. It saves me from that same mistake almost every week.