Merge pull request #4 from pbosetti/master

Truncate the file to zero length on opening when "w" mode is set
fix RSTRING_PTR usage.