Are students allowed to read recommendation letters written for them?
Legally, in the USA, students are entitled to access their educational records. (I assume that there are similar regulations in some other countries.) This poses an obvious problem with letters of recommendation, the contents of which may ideally be unknown to their subjects; this makes it possible for the recommender to give completely honest evaluations and discourages students from "shopping" for the most positive references.
The solution is that students normally waive their right to view the recommendation letter. Most colleges now have online recommendation systems for references to use, and there is always a prominent notice that the student has waived access to the letter. I have never had to write a letter when this waiver was not in place. I know a couple colleagues, however, who have gotten recommendation requests that did not include the waiver; their solution was to write a polite e-mail to the student, reminding the student to waive access. (That the faculty involved would not be willing to write the letter without the waiver may or may not have been made explicit.)
As noted in the comments, law and custom about letters of recommendation differ by country. In the United States, the student does have access to letters of recommendation unless the student waives that right. There will generally be a notice such as the one you describe, letting you know whether the letter is available to the student.
The second part of your question, "should that affect what I write in the letter?" is the more important part because you already know the letter could be available to the student.
It should not affect what you write. The institution to which the student has applied is depending on you for an honest evaluation of the student's abilities. The student presumably believes your evaluation will be a good one, or you would not have been asked to write a recommendation. If that turns out not to be the case, the student may be disappointed; the potential for disappointment should not influence your recommendation.
Although potential access by the student should not affect what you write, it might affect whether you write. As I wrote in a comment, I decline to write letters when the student does not waive the right of access on grounds that a) the student doesn't trust me and b) the institution to which he is applying will possibly give my letter less weight.
Finally, If you would write a negative recommendation, you have an ethical obligation to decline to write a recommendation and to tell the student, at least in general terms, why not.
Encourage your students to talk with you before giving your name as a referee. That will help you avoid problems like this one. Here is what I tell my own students about such letters: https://professorbrown.net/recommendations/
The state of affairs with regards to letters of recommendation in the US represents the very uncomfortable tension that exists between the principle that students should have access to their educational records (a noble idea, to be sure) on the one hand, and the premise (based on an understanding of human psychology) that letter writers become considerably more likely to provide an honest evaluation when they are assured that their letter will be kept confidential from the student, on the other hand.
For this reason, the game of asking students to waive their legal rights has developed, as described in other answers. Ultimately it seems that human nature and human psychology cannot be defeated by a law, however noble and well-intentioned. Thus students end up not seeing their letters in almost all cases, and somehow the world keeps turning.
As for whether what you write should be affected by the lack of confidentiality, that is up to you. It is easy for others to say, as Bob Brown does in his answer, that it shouldn't. Personally I feel that it is a bit inappropriate for any of us to make a recommendation on this point, since we are not you, don't have or know about your personality, and will not be the ones who will be paying the psychological price of our advice. The one practical piece of advice that I agree with (and that I feel is the course of action I would likely take in this situation) is to email the student, explain that as a matter of personal policy you only write letters for students who agree to waive their right, and ask if he/she can kindly click the appropriate checkbox.