Problems to Extract uniquely mapping reads from BWA MEM alignment
The issue is that you are filtering reads without regard to the pairing so you might filter out one of the mates if one aligns uniquely and the other does not.  You will need to filter out the un-mated reads from the file to have a valid BAM.  


  As I do not see any XA or SA flags there anymore, I wonder what those can be?


I am not sure what this means.  The grep should remove those flags and only leave records without them.

As a side note if you don't want split alignments I would recommend using a different aligner such as BWA aln or BowTie2