My question concerns the class Person with the datatype properties hasFirstName, hasLastName, hasDateOfBirth, hasGender
Without knowing Jena, I do not see any place in your code where you only select the male entries.
Check that while (instances.hasNext()) { loop to see what instances it loops through.
Because you write for each of that instances a line, the writeLine() method writes both, male and female entries, it might be that
ExtendedIterator instances = onto.person.listInstances();
returns the two male and female entries you see in your file.
Also, your example RDF entry has a value of H for gender, but in your code you are using M and Fto check it.