Fixed the issue. I had created a new subroutine just for that code, and I guess the program never called on that subroutine, so I moved it into the main subroutine and now it works fine.
For future reference, how do you call up a subroutine? (I should probably read the help section 😁)