I came to the USA on a B1/B2 visa and left as planned after three weeks. I tried to hand in the DHS Departure Record to the officer at the airport passport control but he was not interested. I still have it now. I heard that when people leave with a commercial airline, the departure is recorded automatically. Can I be sure of this and that I will not have problems with the immigration officials in the future?
Per the CBP website, short-term visitors (< 30 days) can retain their I-94 departure record for subsequent visits. As such, most countries are straying away from paper documents for their fallibility, and moving to electronic record keeping for border entry and exit - for visitors and citizens alike.
Further clarification from the website -
In general, if you have been admitted to the United States under most visa classifications if you take a short trip (30 days or less) to Canada or Mexico, you may retain your I-94/I-94W, so that when you resume your visit to the United States you are readmitted for the balance of the time remaining on your I-94/I-94W.
I am not sure how it works when you leave the US on a commercial airline, but to answer the general question: Yes, that could be a problem.
When leaving the U.S. for Mexico you may forget about the departure card. In Tijuana for example you just go through a revolving gate with no US or Mexican border officials anywhere in sight.
I was on my way to Argentina, so I had no intention to come back to the US anytime soon. After finding some Mexican officials to get my entry stamp I walked back over the freeway to the other side to the area where you enter the US from Mexico. I called a US border official to the fence and handed him my departure record. He asked whether I would come back to the US and then took it. I asked him what would have happened if I hadn't give it back to him.
He explained: As the US had no record of me leaving the country, after the 90 days I would have been considered an illegal alien living in the US. It would be on record and the next time I would enter the US I could be in trouble and could be refused entry.
Later one in Mexico I met several people who also crossed over from the US and did not give back their departure record at the border. I convinced them to hand in their card at the next US consulate.