Trains in India can be booked up to 120 days in advance. This means buying a ticket in advance is wise. If it is impossible for you to book in advance, there are a few ways of arranging a ticket more last minute. I've listed some of them here.
Women have to be careful in Delhi. I love Delhi and hope you will too. There are plenty of very friendly intelligent people here. But there are also some nasty bastards, so using common sense when it comes to travelling at night is a good idea.