I have done linear regression and plotted the data, the regression line and also the confidence interval (for 95% confidence). However it seems that most of the data points fall outside the confidence interval. So how am I supposed to interpret the confidence interval. It cannot be I am 95% confident that the data point will be this close to the regression line since a lot more than 5% of the data points do not fall in that area. So what does it mean then?
There are two 95% CI you can derive from your data. One is the 95% CI of the regression line, which is the red one in the attached illustration. The code you provided is intended for plotting this 95% CI. Now, because it's for the line, not for the data points, as you get more data, the precision improves, and the band will narrow down. Your cited code is a somewhat special case because the sample size is only 7, so the 95% CI of the line happened to include about 90% of the data points; it's just a coincidence.
The interval that approximately includes 95% of the data points is shown below in green. I am not sure what it is called, but generally from what I have collected on this site, it should not be called confidence interval. I think you're looking to get these kind of lines, but have been using the incorrect code.
The one that matters more often is the red one. And for proper interpretation, other users have provided links to some useful posts.