1.- Check if there's a blank or space or CR or NL at the end of the RecordSelectionFormula
Obviously you are not going to 'see' it, but if there's one, then the cursor is going to be in the next line of the code
Delete it and test

2.- If point 1 is not the solution then export the rpt to Report Definition format, Destination DiskFile
Please, post attach the created txt file