It's probably not your coding as it's pretty straightforward and you are getting the download box.
The only problem is that the name on the 'download box' is the name of the PHP file that produces it, not the particular file that the script is programmed to download.
I do know that the differences between 5.5 and 6 are minimal, so the bug might still apply.