refactoring
- read all file contents instead of reading one by one
- using memset instead of strcpy