Improved file parsing with regex