Tried to locate the bug
Added some more error handling code, not sure if it's helpful
Altered the style a little bit
A new approach to s5_write_file and s5_read_file