"syntax error, unexpected end of file" Upon enabling modules I'm getting a syntax error when enabling modules.  This is happening intermittently and it isn't specific to any module in particular, which is making it impossible for me to track down.  Here is the error I'm receiving today: 


  Parse error: syntax error, unexpected end of file in sites/all/modules/contrib/headerimage/headerimage.module on line 821


Line 821 is the very last line of the file, and the syntax looks fine to me.  When I get a similar error when enabling modules, it's always complaining about the last line.  There are never any missing brackets.  I've disabled any custom modules I wrote thinking that it could be my code causing this, but I've had no success.

I was wondering if anyone has run into this, if they have any suggestions, or possibly a method to troubleshoot this.

-- EDIT --

I was able to resolve the syntax errors for this particular module (headerimage).  I had to delete the very last line in two of the files and re-add them manually.  They were closing brackets "}".

I'm not convinced that this is the correct fix.  Maybe it's some kind of encoding issue?  Any thoughts?
I figured out what this was. It wasn't necessarily related to Drupal or PHP syntax, but the answer might save someone else some stress.

I had VMWare Fusion on my Mac running a Linux VM with Apache/MySQL/PHP server.  The webroot for Apache was a shared directory on my host machine which contained my Drupal install. I did this so I can have the benefit of a Linux web server while being able to edit my code locally on my host.

This works when serving up the site, but whenever I used Drush on the VM to install a module, there was always a hidden line appended to the module's files that Vi didn't pick up, which is why the syntax error was always on the last line. I'm assuming it had to do with the hgfs filesystem used for sharing between my host and the VM.  

Once I removed the VM sharing and modified everything on the VM itself, all of my problems went away. Downloading modules with Drush no longer produces these syntax errors.

Here is a related thread on the Drush issue queue where people are having similar issues.

https://drupal.org/node/1948962

Thanks to those who gave their feedback.
--richard